Free web hosting music - Appendix H Elevator Model (on CD) 1433 163

Appendix H Elevator Model (on CD) 1433 163 // Person exits Elevator 164 sendPersonMoveEvent( PERSON_EXITING_ELEVATOR ); 165 166 // walking from elevator takes five seconds 167 pauseThread( 2 * TIME_TO_WALK ); 168 169 // Person exits simulation 170 sendPersonMoveEvent( PERSON_EXITED ); 171 172 } // end method run 173 174 // Person enters Elevator 175 private void enterAndRideElevator() 176 { 177 // Person enters Elevator 178 sendPersonMoveEvent( PERSON_ENTERING_ELEVATOR ); 179 180 // set Person Location to Elevator 181 Floor floorLocation = ( Floor ) getLocation(); 182 setLocation( 183 floorLocation.getElevatorShaft().getElevator() ); 184 185 // Person takes one second to enter Elevator 186 pauseThread( 1000 ); 187 188 // register for Elevator’s Door’s doorOpen event 189 Door elevatorDoor = getLocation().getDoor(); 190 elevatorDoor.addDoorListener( this ); 191 192 // pressing Elevator Button takes one second 193 sendPersonMoveEvent( PERSON_PRESSING_BUTTON ); 194 pauseThread( 1000 ); 195 196 // get Elevator’s Button 197 Button elevatorButton = getLocation().getButton(); 198 199 // press Elevator’s Button 200 elevatorButton.pressButton( location ); 201 202 // Door closing takes one second 203 pauseThread( 1000 ); 204 205 // ride in Elevator 206 Elevator elevator = ( Elevator ) getLocation(); 207 elevator.ride(); 208 209 // Person finished riding Elevator 210 211 // unregister for Elevator’s Door’s doorOpen event 212 elevatorDoor.removeDoorListener( this ); 213 214 } // end method enterAndRideElevator Fig. H.13 Class Personrepresents the Personthat rides the Elevator. The Personoperates asynchronously with other objects (part 5 of 7).
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

Leave a Reply