Created
November 18, 2019 15:17
-
-
Save Naomi-Dennis/8fb359e7cc1792060a82105d15b9c0e3 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
/* Add device interface */ | |
interface Device{ } | |
interface VideoCable{ | |
public void connect(Device device); | |
} | |
class Laptop implements Device{} | |
class DisplayPortCable implements VideoCable{ | |
public void connect(Device device){ | |
connectedDevice = device; | |
} | |
private Device connectedDevice; | |
} | |
class Monitor{ | |
public Monitor(VideoCable videoConnector){ | |
this.videoConnector = videoConnector; | |
} | |
public void connectToDevice(Device device){ | |
videoConnector.connect(device); | |
} | |
private VideoCable videoConnector; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment