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
class EntertainmentDevice: | |
def _connectToDeviceViaHDMICord(self, device): None | |
def _connectToDeviceViaRCACord(self, device): None | |
def _connectToDeviceViaEthernetCord(self, device): None | |
def _connectDeviceToPowerOutlet(self, device): None | |
class Television(EntertainmentDevice): | |
def connectToDVD(self, dvdPlayer): | |
self._connectToDeviceViaRCACord(dvdPlayer) |
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
class WallPoweredDevice: | |
def plugInPower(self, device): | |
self.__connectToDeviceViaPowerOutlet(device) | |
def __connectToDeviceViaPowerOutlet(self, device): None | |
class AnalogDevice: | |
def _connectToDeviceViaRCACord(self, device): None | |
class DigitalDevice: |
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
class WallPoweredDevice { | |
public void plugInPower() { | |
} | |
} | |
interface InternetDevice { | |
public void connectToDeviceViaEthernetCord(InternetDevice device); | |
} | |
class Router extends WallPoweredDevice implements InternetDevice { |
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
class Laptop{} | |
class DisplayPortCord{ | |
public void connect(Laptop device){ | |
connectedDevice = device; | |
} | |
private Laptop connectedDevice; | |
} |
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
class Laptop{} | |
/* Added video interface */ | |
interface VideoCable{ | |
public void connect(Laptop device); | |
} | |
class DisplayPortCable implements VideoCable{ | |
public void connect(Laptop device){ | |
connectedDevice = device; |
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{ |
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
class Laptop; end | |
class DisplayPortCord | |
def connect(device) | |
self.connectedDevice = device; | |
end | |
private | |
attr_accessor :connectedDevice; | |
end |
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
class Monitor | |
def initialize(videoConnector) | |
self.videoConnector = videoConnector; | |
end | |
def connectToDevice(device) | |
if videoConnector.kind_of? DisplayPortCord | |
videoConnector.connect(device); | |
elsif videoConnector.kind_of? HdmiCord | |
videoConnector.connectToSomething(device) |
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
class Game{ | |
public void start(){ | |
while(!winnerFound){ | |
renderBoard(); | |
playerTurn(); | |
winnerFound = detectWinner(); | |
} | |
} | |
public void playerTurn(){} |
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
interface Board{ | |
public void render(); | |
} | |
interface GameLogic{ | |
public void startPlayerTurn(); | |
public boolean winnerFound(); | |
} | |
class GameCoordinator{ |
OlderNewer