This file contains hidden or 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 Queen extends ChessPiece{ | |
| public Queen() { | |
| this.pieceType="Queen"; | |
| } | |
| @Override | |
| void moveTo(String position) { | |
| this.currentPosition = position; | |
| System.out.println(pieceType+" Piece Moved to - "+ position); | |
| } |
This file contains hidden or 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 Rook extends ChessPiece{ | |
| public Rook() { | |
| this.pieceType="Rook"; | |
| } | |
| @Override | |
| void moveTo(String position) { | |
| this.currentPosition = position; | |
| System.out.println(pieceType+" Piece Moved to - "+ position); | |
| } | |
| } |
This file contains hidden or 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 java.util.HashMap; | |
| import java.util.Map; | |
| public class PieceBox { | |
| private static Map<String, ChessPiece> chessPieceMap = new HashMap<String, ChessPiece>(); | |
| static | |
| { | |
| chessPieceMap.put("bishop", new Bishop()); | |
| chessPieceMap.put("king", new King()); |
This file contains hidden or 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 PlayChessTest { | |
| public static void main(String[] args) { | |
| PlayChessTest playChess = new PlayChessTest(); | |
| playChess.initBoard(); | |
| } | |
| /** | |
| * Arranging the pieces on the box | |
| */ | |
| private void initBoard() { |
This file contains hidden or 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 DominosPizza { | |
| private String pizzaType; | |
| private String name; | |
| private String quantity; | |
| private String typeOfDelivery; | |
| public DominosPizza(String pizzaType, String name, String quantity, String typeOfDelivery) { | |
| this.pizzaType = pizzaType; | |
| this.name = name; | |
| this.quantity = quantity; | |
| this.typeOfDelivery = typeOfDelivery; |
This file contains hidden or 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 PizzaBuilderTest { | |
| public static void main(String[] args) { | |
| DominosPizza pizza= new DominosPizza.HandTossedPizzaBuilder() | |
| .setName("Mexican Green Wave") | |
| .setQuantity("Large") | |
| .setTypeOfDelivery("Home Delivery") | |
| .setAddon("Onion") | |
| .setAddon("Cheese") | |
| .build(); | |
This file contains hidden or 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 TestPresidentOfTheCountry { | |
| public static void main(String[] args) { | |
| PresidentOfTheCountry.getPresident();//Creating new instance | |
| PresidentOfTheCountry.getPresident();//returning already created instance | |
| } | |
| } |
This file contains hidden or 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 PresidentOfTheCountry { | |
| private static PresidentOfTheCountry president; | |
| private PresidentOfTheCountry() { | |
| } | |
| public static PresidentOfTheCountry getPresident(){ | |
| if(president == null){ | |
| System.out.println("No President yet assigned, Initializing new President!!!"); |
This file contains hidden or 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 abstract class Employee { | |
| public abstract String getExperiance(); | |
| public abstract String getPreferredLocation(); | |
| public abstract String getRole(); | |
| @Override | |
| public String toString(){ | |
| return "Experiance= "+this.getExperiance()+", PreferredLocation="+this.getPreferredLocation()+", Role="+this.getRole(); | |
| } | |
| } |
This file contains hidden or 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 JavaEmployee extends Employee{ | |
| private String experiance; | |
| private String role; | |
| private String preferredLocation; | |
| public JavaEmployee(String experiance, String role, String preferredLocation) { | |
| super(); | |
| this.experiance = experiance; | |
| this.role = role; |