Java Reference
In-Depth Information
EventProcess
String name
Thread thread
update()
notifyObservers()
waitEvent()
run()
Car
TrafficLight
PhotoCell
Dispenser
StoppingBar
Controller
setGreen()
setRed()
run()
occupy()
clear()
run()
deliver()
withdraw()
run()
raise()
lower()
run()
run()
run()
Figure 11.7 The class diagram
Car
TrafficLight
IN_PhC
Dispenser
Bar
OUT_PhC
Controller
GREEN
setGreen()
occupy()
OCCUPIED
clear()
CLEARED
setRed()
DELIVERED
deliver()
DELIVERED
withdraw()
WITHDRAWN
raise()
UP
UP
occupy()
OCCUPIED
clear()
CLEARED
lower()
DOWN
Figure 11.8 The interaction diagram
interface. It initializes all the components of the car parking system and
listens to the events they raise.
11.5.3
Implementation
The following code implements class TrafficLight , class PhotoCell , class
TicketDispenser and class StoppingBar . The state of each is represented by a
unique Boolean variable. Two methods trigger state transitions that change
 
 
Search WWH ::




Custom Search