Use the Interface Segregation Principle to tidy the following:
interface ICrew
{
function communicate(){}
function useLightSaber(){}
function flyShip(ship:Ship)
}
class Jedi extends Person implements ICrew
{
function communicate()
{
print("Yo WASSUP?")
}
function useLightSaber()
{
if isEquippedWith(Weapon.LIGHTSABER)
{
fushwoon()
wern()
}
}
function flyShip(ship:Ship)
{
ship.addPilot(this)
}
}
class R2D2 extends Robot implements ICrew
{
function communicate()
{
print("Beep di beep squallucks beep")
}
function useLightSaber()
{
// not possible as I don't haz good sword arms
}
function flyShip(ship:Ship)
{
ship.addPilot(this)
}
}