This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyPizza myPizza = new MyPizza.Builder() | |
.setSize(10) | |
.setPepperoni(true); | |
.setBacon(true) | |
.setVeggies(true) | |
.setBlackPepper(true) | |
.build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public class MyPizza{ | |
private int size; | |
private boolean cheese; | |
private boolean pepperoni; | |
private boolean bacon; | |
private boolean veggies; | |
private boolean blackPepper; | |
public MyPizza(int size,boolean cheese, boolean pepperoni, boolean bacon, boolean veggies, boolean blackPepper){ | |
this.size = size; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lombok.Getter; | |
import lombok.Setter; | |
@Getter | |
@Setter | |
Public class MyPizza{ | |
private int size; | |
private boolean cheese; | |
private boolean pepperoni; | |
private boolean bacon; | |
public void MyPizza(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyPizza mypizza = new MyPizza(12); | |
mypizza.setCheese(true); | |
mypizza.setPepperoni(true); | |
mypizza.setBacon(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyPizza(int size) { ... } | |
MyPizza(int size, boolean cheese) { ... } | |
MyPizza(int size, boolean cheese, boolean pepperoni) { ... } | |
MyPizza(int size, boolean cheese, boolean pepperoni, boolean bacon) { ... } | |
MyPizza(int size, boolean cheese, boolean pepperoni, boolean bacon, boolean veggisAllowed) { ... } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int mid = (high + low)>>>1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int mid = low + ((high - low) / 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int mid = (low + high) / 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int binarySearch(int[] a, int key) { | |
int low = 0; | |
int high = a.length - 1; | |
while (low <= high) { | |
int mid = (low + high) / 2; | |
int midVal = a[mid]; | |
if (midVal < key) | |
low = mid + 1 | |
else if (midVal > key) | |
high = mid - 1; |