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 CEO extends ChainHandler implements Employee { | |
@Override | |
public void handleRequest(ChainedRequest chainedRequest) { | |
switch (chainedRequest.getRequestType()) { | |
case CONFERENCE: | |
System.out.println("CEO can approve anything"); | |
break; |
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 Subway { | |
//Member Variables | |
private String bread; | |
private boolean toast; | |
private boolean veg; | |
private boolean nonVeg; | |
private boolean onion; | |
private boolean tomato; |
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 Main { | |
public static void main(String[] args) { | |
Subway subway = Subway.builder("Wheat", "Grilled") | |
.cheese("Mozzarella") | |
.onion() | |
.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 Subway { | |
private String bread; | |
private String toast; | |
private String cheese; | |
private boolean onion; | |
private boolean tomato; | |
//Private constructor to avoid direct instantiation of the Subway class | |
private Subway(Builder builder) { |
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 interface Bread { | |
Toast bread(String bread); | |
} | |
public interface Toast { | |
Type toast(boolean toast); | |
} |
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 Subway { | |
//Member Variables | |
private String bread; | |
private boolean toast; | |
private boolean veg; | |
private boolean nonVeg; | |
private boolean onion; | |
private boolean tomato; | |
private boolean olives; |
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 Main { | |
public static void main(String[] args) { | |
Subway subwayVegetarian = Subway.builder().bread("Wheat") | |
.toast(true) | |
.veg() | |
.olives().tomato().onion() | |
.prepare() | |
.cheese("Mozzarella") |
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 interface Animal { | |
String makeNoise(); | |
} |
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 Cat implements Animal { | |
@Override | |
public String makeNoise() { | |
return "Meow"; | |
} | |
} |
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 Dog implements Animal { | |
@Override | |
public String makeNoise() { | |
return "Woof"; | |
} | |
} |
OlderNewer