Skip to content

Instantly share code, notes, and snippets.

View techindepth's full-sized avatar
👋

ANISH ANTONY techindepth

👋
View GitHub Profile
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);
}
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);
}
}
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());
public class PlayChessTest {
public static void main(String[] args) {
PlayChessTest playChess = new PlayChessTest();
playChess.initBoard();
}
/**
* Arranging the pieces on the box
*/
private void initBoard() {
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;
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();
public class TestPresidentOfTheCountry {
public static void main(String[] args) {
PresidentOfTheCountry.getPresident();//Creating new instance
PresidentOfTheCountry.getPresident();//returning already created instance
}
}
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!!!");
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();
}
}
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;