Created
August 27, 2018 08:47
-
-
Save IvoIvanov77/c00e25d4a618de21915022e152b55115 to your computer and use it in GitHub Desktop.
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) { | |
PrinterController.connectToPrinterA().commandA1(); | |
PrinterController.connectToPrinterB().commandB1(); | |
PrinterController.connectToPrinterC().commandC1(); | |
} | |
} |
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 PrinterA { | |
private static PrinterA instance; | |
private PrinterA() { | |
} | |
public static PrinterA getInstance(){ | |
if(instance == null){ | |
return new PrinterA(); | |
} | |
return instance; | |
} | |
public void commandA1(){ | |
// TODO: implement me | |
} | |
public void commandA2(){ | |
// TODO: implement me | |
} | |
} |
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 PrinterB { | |
private static PrinterB instance; | |
private PrinterB() { | |
} | |
public static PrinterB getInstance(){ | |
if(instance == null){ | |
return new PrinterB(); | |
} | |
return instance; | |
} | |
public void commandB1(){ | |
// // TODO: implement me | |
} | |
public void commandB2(){ | |
// // TODO: implement me | |
} | |
} | |
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 PrinterC { | |
private static PrinterC instance; | |
private PrinterC() { | |
} | |
public static PrinterC getInstance(){ | |
if(instance == null){ | |
return new PrinterC(); | |
} | |
return instance; | |
} | |
public void commandC1(){ | |
// TODO: implement me | |
} | |
public void commandC2(){ | |
// TODO: implement me | |
} | |
} |
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 PrinterController { | |
private PrinterController() { | |
} | |
public static PrinterA connectToPrinterA(){ | |
return PrinterA.getInstance(); | |
} | |
public static PrinterB connectToPrinterB(){ | |
return PrinterB.getInstance(); | |
} | |
public static PrinterC connectToPrinterC(){ | |
return PrinterC.getInstance(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment