Bulletproof web design - Appendix H Elevator Model (on CD) 1431 59

Appendix H Elevator Model (on CD) 1431 59 // set Person on Floor where Door opened 60 setLocation( doorEvent.getLocation() ); 61 62 // interrupt Person’s sleep method in run method and 63 // Elevator’s ride method 64 interrupt(); 65 } 66 67 // invoked when Door has closed 68 public void doorClosed( DoorEvent doorEvent ) {} 69 70 // set Person Location 71 private void setLocation( Location newLocation ) 72 { 73 location = newLocation; 74 } 75 76 // get current Location 77 private Location getLocation() 78 { 79 return location; 80 } 81 82 // get identifier 83 public int getID() 84 { 85 return ID; 86 } 87 88 // set if Person should move 89 public void setMoving( boolean personMoving ) 90 { 91 moving = personMoving; 92 } 93 94 // get if Person should move 95 public boolean isMoving() 96 { 97 return moving; 98 } 99 100 // Person either rides or waits for Elevator 101 public void run() 102 { 103 sendPersonMoveEvent( PERSON_CREATED ); 104 105 // walk to Elevator 106 pauseThread( TIME_TO_WALK ); 107 setMoving( false ); 108 109 // Person arrived at Floor Button 110 sendPersonMoveEvent( PERSON_ARRIVED ); Fig. H.13 Class Personrepresents the Personthat rides the Elevator. The Personoperates asynchronously with other objects (part 3 of 7).
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Leave a Reply