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 interface Image { | |
| void display(); | |
| } |
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 ClientMain { | |
| public static void main(String[] args) { | |
| ComputerFacade computer = new ComputerFacade(); | |
| computer.start(); | |
| } | |
| } |
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 ComputerFacade { | |
| static private final long BOOT_ADDRESS = 0; | |
| static private final long BOOT_SECTOR = 0; | |
| static private final int SECTOR_SIZE = 0; | |
| private CPU processor; | |
| private Memory ram; | |
| private HardDrive hd; | |
| public ComputerFacade() { |
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 Memory { | |
| public void load(long position, byte[] data) { | |
| System.out.println("Memory: loading... " ); | |
| } | |
| } |
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 HardDrive { | |
| public byte[] read(long lba, int size) { | |
| System.out.println("HardDrive: reading..."); | |
| return null; | |
| } | |
| } |
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
| class CPU { | |
| public void freeze() { | |
| System.out.println("CPU: freezing..."); | |
| } | |
| public void jump(long position) { | |
| System.out.println("CPU: jumping..."); | |
| } | |
| public void execute() { | |
| System.out.println("CPU: executing..."); | |
| } |
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 interface Command { | |
| void execute(); | |
| } | |
| public class ClientMain { | |
| static public void main(String[] args) { | |
| ReceiverA receiverA = new ReceiverA(); | |
| ReceiverB receiverB = new ReceiverB(); | |
| Invoker invoker = new Invoker(); |
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 Client { | |
| static public void main(String[] args) { | |
| CommandA commandA = new CommandA(new ReceiverA()); | |
| CommandB commandB = new CommandB(new ReceiverB()); | |
| Invoker invoker = new Invoker(); | |
| invoker.setCommand(0, commandA); | |
| invoker.setCommand(1, commandB); | |
| invoker.onButtonWasPushed(0); |
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 Invoker { | |
| private Command[] commands; | |
| private Command undoCommand; | |
| public Invoker() { | |
| commands = new Command[2]; | |
| undoCommand = new NoCommand(); | |
| } | |
| public void setCommand(int slot, Command command) { |
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 NoCommand implements Command { | |
| @Override | |
| public void execute() { | |
| System.out.println("No Command!"); | |
| } | |
| @Override | |
| public void undo() { | |
| System.out.println("No Command!"); | |
| } |