Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public interface Heater {
  2. public void heat();
  3. public void noHeat();
  4. }
  5.  
  6. public interface Cooler {
  7. public void cool();
  8. public void noCool();
  9. }
  10.  
  11. public interface Device {
  12. public void switchOn();
  13. public void switchOff();
  14. }
  15.  
  16. public class DeviceImpl {
  17. public DeviceImpl(...) {...}
  18. public switchOn() {...}
  19. public switchoff() {...}
  20. }
  21.  
  22. public class Heater {
  23. Device device;
  24.  
  25. public Heater() {
  26. this.device = new DeviceImpl(...);
  27. }
  28.  
  29. public void heat() {
  30. this.device.switchOn();
  31. }
  32.  
  33. public void noHeat() {
  34. this.device.switchOff();
  35. }
  36. }
  37.  
  38. public class Cooler {
  39. Device device;
  40.  
  41. public Cooler() {
  42. this.device = new DeviceImpl(...);
  43. }
  44.  
  45. public void cool() {
  46. this.device.switchOn();
  47. }
  48.  
  49. public void noCool() {
  50. this.device.switchOff();
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement