1418 Elevator Model (on CD) Appendix H 61 (Web hosting reviews)
1418 Elevator Model (on CD) Appendix H 61 thread.start(); 62 } 63 } // end method turnOnLight 64 65 // turn off Light 66 public void turnOffLight( Location location ) 67 { 68 if ( lightOn ) { 69 70 lightOn = false; 71 72 // send LightEvent to LightListener 73 lightListener.lightTurnedOff( 74 new LightEvent( this, location ) ); 75 } 76 } // end method turnOffLight 77 78 // return whether Light is on or off 79 public boolean isLightOn() 80 { 81 return lightOn; 82 } 83 84 // invoked when Elevator has departed 85 public void elevatorDeparted( 86 ElevatorMoveEvent moveEvent ) 87 { 88 turnOffLight( moveEvent.getLocation() ); 89 } 90 91 // invoked when Elevator has arrived 92 public void elevatorArrived( 93 ElevatorMoveEvent moveEvent ) 94 { 95 turnOnLight( moveEvent.getLocation() ); 96 } 97 } Fig. H.10 Class Lightrepresents a Lighton the Floorin the model (part 3 of 3). According to Fig. 15.21, class Light contains attribute lightOn (line 11), which represents the state of the Light (on or off). In addition, Fig. 15.21 specifies that class Lightcontains methods turnOnLight(lines 29 63) and turnOffLight(lines 66 76). Line 33 of method turnOnLightsets attribute lightOnto true, and lines 36 37 call method lightTurnedOn of the lightListener (line 17). In our model, the ElevatorShaft is the lightListener the ElevatorShaft receives events from the Lightand sends them to the ElevatorModel, which sends them to the ElevatorView. The ElevatorShaftuses method setLightListener(lines 23 26) to register for LightEvents. Method turnOffLight sets attribute lightOn to false, then calls method lightTurnedOffof the lightListener. We decided in Section 15.12 to make class Lightan active class, so that the Light turns itself off after three seconds of being illuminated. Lines 42 59 of method turnOn
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.