Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Naomi-Dennis/8fb359e7cc1792060a82105d15b9c0e3 to your computer and use it in GitHub Desktop.
Save Naomi-Dennis/8fb359e7cc1792060a82105d15b9c0e3 to your computer and use it in GitHub Desktop.
/* 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