Exercise 1 solution using inheritance

abstract Lamp
xor shape
ball
square
diamond
TrafficLightSystem
Lamps
Red : Lamp
[ no diamond ]
Yellow : Lamp
[ no square ]
Green : Lamp
[ ball ]
allBalls ?
[ all l : Lamp | l.shape.ball ]
xor orientation
vertical
horizontal

Back to country specific features