1432 Elevator (Yahoo web space) Model (on CD) Appendix H 111

1432 Elevator Model (on CD) Appendix H 111 112 // get current Door on Floor 113 Door currentFloorDoor = location.getDoor(); 114 115 // determine if Door on Floor is open 116 try { 117 118 boolean doorOpen = currentFloorDoor.isDoorOpen(); 119 120 // if Door on Floor is closed 121 if ( !doorOpen ) { 122 123 // press Floor Button 124 sendPersonMoveEvent( PERSON_PRESSING_BUTTON ); 125 pauseThread( 1000 ); 126 127 // register for Floor Door’s doorOpen event 128 currentFloorDoor.addDoorListener( this ); 129 130 // press Floor’s Button to request Elevator 131 Button floorButton = getLocation().getButton(); 132 floorButton.pressButton( getLocation() ); 133 134 // wait for Floor’s Door to open 135 sleep( TIME_WAITING ); 136 137 // unregister with Floor’s Door if too long 138 currentFloorDoor.removeDoorListener( this ); 139 } 140 141 // if Door on Floor is open, ride Eelevator 142 else 143 enterAndRideElevator(); 144 } 145 146 // handle exception when interrupted from waiting 147 catch ( InterruptedException interruptedException ) { 148 149 // Person unregisters for Floor’s Door doorOpen event 150 currentFloorDoor.removeDoorListener( this ); 15 15 // enter and ride Elevator when Door on Floor opens, 15 pauseThread( 1000 ); 15 enterAndRideElevator(); 15 } 15 15 // waiting for Elevator’s Door to open takes a second 15 pauseThread( 1000 ); 15 160 // begin walking away from Elevator 161 setMoving( true ); 162 Fig. H.13 Class Personrepresents the Personthat rides the Elevator. The Personoperates asynchronously with other objects (part 4 of 7).
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Leave a Reply