Advertisement
haykart

Untitled

Oct 18th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. /* Complex parts */
  2.  
  3. class CPU {
  4.     public void freeze() { ... }
  5.     public void jump(long position) { ... }
  6.     public void execute() { ... }
  7. }
  8.  
  9. class HardDrive {
  10.     public byte[] read(long lba, int size) { ... }
  11. }
  12.  
  13. class Memory {
  14.     public void load(long position, byte[] data) { ... }
  15. }
  16.  
  17. /* Facade */
  18.  
  19. class ComputerFacade {
  20.     private CPU processor;
  21.     private Memory ram;
  22.     private HardDrive hd;
  23.  
  24.     public ComputerFacade() {
  25.         this.processor = new CPU();
  26.         this.ram = new Memory();
  27.         this.hd = new HardDrive();
  28.     }
  29.  
  30.     public void start() {
  31.         processor.freeze();
  32.         ram.load(BOOT_ADDRESS, hd.read(BOOT_SECTOR, SECTOR_SIZE));
  33.         processor.jump(BOOT_ADDRESS);
  34.         processor.execute();
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement