Appendix H Elevator (Web hosting) Model (on CD) 1419 Lightinstantiate
Appendix H Elevator Model (on CD) 1419 Lightinstantiate a thread that handles this responsibility. Method run(lines 45 57) puts this thread to sleep for three seconds, then turns off the Light. Line 61 of method turn- OnLightstarts the thread. According to Fig. H.2, class Light implements interface ElevatorMoveListener. Lines 85 89 and lines 92 96 list methods elevatorDeparted and elevatorArrived, respectively. In our model, the Lightturns off when the Elevatorhas departed, and the Lightturns on when the Elevatorhas arrived. Class Bell (Fig. H.11) represents the Bell in the model and sends a bellRang event to a BellListenerwhen the Bellhas rung. This event eventually bubbles up to the ElevatorView. The ElevatorViewplays an audio clip of a bell ringing upon receiving a bellRang event. 1 // Bell.java 2 // Represents Bell in simulation 3 package com.deitel.jhtp4.elevator.model; 4 5 // Deitel packages 6 import com.deitel.jhtp4.elevator.event.*; 7 8 public class Bell implements ElevatorMoveListener { 9 10 // BellListener listens for BellEvent object 11 private BellListener bellListener; 12 13 // ring bell and send BellEvent object to listener 14 private void ringBell( Location location ) 15 { 16 if ( bellListener != null ) 17 bellListener.bellRang( 18 new BellEvent( this, location ) ); 19 } 20 21 // set BellListener 22 public void setBellListener( BellListener listener ) 23 { 24 bellListener = listener; 25 } 26 27 // invoked when Elevator has departed 28 public void elevatorDeparted( ElevatorMoveEvent moveEvent ) {} 29 30 // invoked when Elevator has arrived 31 public void elevatorArrived( ElevatorMoveEvent moveEvent ) 32 { 33 ringBell( moveEvent.getLocation() ); 34 } 35 } Fig. H.11 Class Bellrepresents the Bellin the model.
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.