1422 Elevator Model (on CD) Appendix H 66 (Cpanel web hosting)

1422 Elevator Model (on CD) Appendix H 66 // instantiate listener Set 67 elevatorMoveListeners = new HashSet( 1 ); 68 69 // start Elevator on first Floor 70 currentFloorLocation = firstFloor; 71 destinationFloorLocation = secondFloor; 72 73 // register elevatorButton for ElevatorMoveEvents 74 addElevatorMoveListener( elevatorButton ); 75 76 // register elevatorDoor for ElevatorMoveEvents 77 addElevatorMoveListener( elevatorDoor ); 78 79 // register bell for ElevatorMoveEvents 80 addElevatorMoveListener( bell ); 81 82 // anonymous inner class listens for ButtonEvents from 83 // elevatorButton 84 elevatorButton.setButtonListener( 85 new ButtonListener() { 86 87 // invoked when elevatorButton has been pressed 88 public void buttonPressed( ButtonEvent buttonEvent ) 89 { 90 // send ButtonEvent to listener 91 elevatorButtonListener.buttonPressed( 92 buttonEvent ); 93 94 // start moving Elevator to destination Floor 95 setMoving( true ); 96 } 97 98 // invoked when elevatorButton has been reset 99 public void buttonReset( ButtonEvent buttonEvent ) 100 { 101 // send ButtonEvent to listener 102 elevatorButtonListener.buttonReset( 103 buttonEvent ); 104 } 105 } // end anonymous inner class 106 ); 107 108 // anonymous inner class listens for DoorEvents from 109 // elevatorDoor 110 elevatorDoor.addDoorListener( 111 new DoorListener() { 112 113 // invoked when elevatorDoor has opened 114 public void doorOpened( DoorEvent doorEvent ) 115 { 116 // get Location associated with DoorEvent 117 Location location = doorEvent.getLocation(); Fig. H.12 Class Elevatorrepresents the Elevatortraveling between two Floors, operating asynchronously with other objects (part 3 of 9).
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Leave a Reply