Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 50

Appendix F – Elevator View

Outline
F.1 Introduction
F.2 Class Objects
F.3 Class Constants
F.4 Class Constructor
F.5 Event Handling
F.5.1 ElevatorMoveEvent types
F.5.2 PersonMoveEvent types
F.5.3 DoorEvent types
F.5.4 ButtonEvent types
F.5.5 BellEvent types
F.5.6 LightEvent types
F.6 Artifacts Revisited
F.7 Conclusion

 2003 Prentice Hall, Inc. All rights reserved.


F.1 Introduction

• Class ElevatorView
– Graphical representation of elevator-simulation model
– Largest class in simulation

 2003 Prentice Hall, Inc. All rights reserved.


1 // ElevatorView.java Outline
2 // View for ElevatorSimulation
3 package com.deitel.jhtp5.elevator.view;
4 ElevatorView.ja
5 // Java core packages
6 import java.awt.*;
va
7 import java.awt.event.*; ElevatorView
8 import java.util.*; displays the elevator
9 import java.applet.*; simulation model.
10
11 // Java extension package ElevatorView implements Lines 18-20
12 import javax.swing.*;
ElevatorSimulationListener,
13
14 // Deitel packages
which inherits from all listener interfaces
Lines 23-24
15 import com.deitel.jhtp5.elevator.event.*;
16 import com.deitel.jhtp5.elevator.ElevatorConstants;
17
18 public class ElevatorView extends JPanel
19 implements ActionListener, ElevatorSimulationListener,
20 ElevatorConstants {
21
22 // ElevatorView dimensions
23 private static final int VIEW_WIDTH = 800; Constants for width and height
24 private static final int VIEW_HEIGHT = 435; of ElevatorView
25
26 // offset for positioning Panels in ElevatorView
27 private static final int OFFSET = 10;

 2003 Prentice Hall, Inc.


All rights reserved.
28 Outline
29 // Elevator repaints components every 50 ms
Constant for animation
30 private static final int ANIMATION_DELAY = 50;
31 (refresh) rate
ElevatorView.ja
32 // horizontal distance constants
33 private static final int PERSON_TO_BUTTON_DISTANCE = 400;
va distances
Constants for
34 private static final int BUTTON_TO_ELEVATOR_DISTANCE = 50; that Person ElevatorView
must travel
35 private static final int PERSON_TO_ELEVATOR_DISTANCE = displays the elevator
36 PERSON_TO_BUTTON_DISTANCE + BUTTON_TO_ELEVATOR_DISTANCE; simulation model.
37
Time constants for
38 // times walking to Floor's Button and Elevator
39 private static final int TIME_TO_BUTTON = 3000; // 3 seconds
distancesLine
Person
30
40 private static final int TIME_TO_ELEVATOR = 1000; // 1 second travels
41 Lines 33-36
42 // time traveling in Elevator (5 seconds)
43 private static final int ELEVATOR_TRAVEL_TIME = 5000;
Lines 39-40
44 Constant for time
45 // Door images for animation
required
Line 43to travel
46 private static final String doorFrames[] = {
47 "images/door1.png", "images/door2.png", "images/door3.png",
between Floors
48 "images/door4.png", "images/door5.png" }; Lines 46-54
49 Constants for names of
50 // Person images for animation
graphics files for Door
51 private static final String personFrames[] = {
52 "images/bug1.png", "images/bug2.png", "images/bug3.png",
and Person
53 "images/bug4.png", "images/bug5.png", "images/bug6.png",
54 "images/bug7.png", "images/bug8.png" };
55

 2003 Prentice Hall, Inc.


All rights reserved.
56 // Light images for animation Outline
57 private static final String lightFrames[] = {
58 "images/lightOff.png", "images/lightOn.png" };
59 ElevatorView.ja
60 // Floor Light images for animation
61 private static final String firstFloorLightFrames[] = {
va
62 "images/firstFloorLightOff.png", ElevatorView
63 "images/firstFloorLightOn.png" }; Constants forthe
displays names of
elevator
64 graphics Light,
files formodel.
simulation
65 private static final String secondFloorLightFrames[] = { Button and Bell
66 "images/secondFloorLightOff.png",
67 "images/secondFloorLightOn.png", };
Lines 57-84
68
69 // Floor Button images for animation
70 private static final String floorButtonFrames[] = {
71 "images/floorButtonUnpressed.png",
72 "images/floorButtonPressed.png",
73 "images/floorButtonLit.png" };
74
75 // Elevator Button images for animation
76 private static final String elevatorButtonFrames[] = {
77 "images/elevatorButtonUnpressed.png",
78 "images/elevatorButtonPressed.png",
79 "images/elevatorButtonLit.png" };
80
81 // Bell images for animation
82 private static final String bellFrames[] = {
83 "images/bell1.png", "images/bell2.png",
84 "images/bell3.png" };

 2003 Prentice Hall, Inc.


All rights reserved.
85 Outline
86 private static final String floorImage =
87 "images/floor.png";
88 private static final String ceilingImage = ElevatorView.ja
Ceiling and wall are not
89 "images/ceiling.png";
90 private static final String elevatorImage =
in model,va
but we display
91 "images/elevator.png"; themElevatorView
for realism
92 private static final String wallImage = displays the elevator
93 "images/wall.jpg"; simulation model.
94 private static final String elevatorShaftImage =
95 "images/elevatorShaft.png";
96
Lines 88-89 and 92-93
97 // audio files
Constants for names
98 private static final String bellSound = "bell.wav"; Lines 98-103
99 private static final String doorOpenSound = "doorOpen.wav";
of sound-clip files
100 private static final String doorCloseSound = "doorClose.wav";
Line 104
101 private static final String elevatorSound = "elevator.au";
102 private static final String buttonSound = "button.wav";
103 private static final String walkingSound = "walk.wav"; Lines 107-111
104 private static final String elevatorMusicSound = "liszt.mid";
Constant for name of
105 “elevator music” file
106 // ImagePanels for Floors, ElevatorShaft, wall and ceiling ImagePanels represent
107 private ImagePanel firstFloorPanel;
stationary objects in model (e.g.,
108 private ImagePanel secondFloorPanel;
109 private ImagePanel elevatorShaftPanel;
Floor, ElevatorShaft)
110 private ImagePanel wallPanel;
111 private ImagePanel ceilingPanel;
112

 2003 Prentice Hall, Inc.


All rights reserved.
113 // MovingPanels for Elevator Outline
MovingPanels represent
114 private MovingPanel elevatorPanel;
115
objects that can move and
116 // AnimatedPanels for Buttons, Bell, Lights and Door have only one associated
AnimatedPanels ElevatorView.ja
represent
117 private AnimatedPanel firstFloorButtonPanel; image (e.g., Elevator)
118 private AnimatedPanel secondFloorButtonPanel; objects in model va
with multiple
119 private AnimatedPanel elevatorButtonPanel; ElevatorView
images (e.g., Button, Person,
120 private AnimatedPanel bellPanel;
Light, Bell displays the elevator
and Door)
121 private AnimatedPanel elevatorLightPanel; simulation model.
122 private AnimatedPanel firstFloorLightPanel;
123 private AnimatedPanel secondFloorLightPanel;
124 private AnimatedPanel doorPanel;
Line 114
125
126 // List containing AnimatedPanels for all Person objects Lines 117-124
127 private java.util.List personAnimatedPanels;
128 List stores AnimatedPanels
129 // AudioClips for sound effects associated withLine 127
Persons
130 private AudioClip bellClip;
AudioClips for playing sound clips
131 private AudioClip doorOpenClip; Lines 130-135
132 private AudioClip doorCloseClip;
133 private AudioClip elevatorClip; Line 138
134 private AudioClip buttonClip;
135 private AudioClip walkClip;
136
137 // ElevatorMusic to play in Elevator
138 private AudioClip elevatorMusicClip;
elevatorMusicClip plays music
139 when Person rides Elevator

 2003 Prentice Hall, Inc.


All rights reserved.
140 // Timer for animation controller; Outline
141 private javax.swing.Timer animationTimer;
142 Timer determines
143 // distance from top of screen to display Floors when to redraw images
ElevatorView.ja
144 private int firstFloorPosition;
145 private int secondFloorPosition;
va
146 ElevatorView
147 // Elevator's velocity displays the elevator
148 private double elevatorVelocity; simulation model.
149
150 // ElevatorView constructor
151 public ElevatorView()
Line 141
152 {
Using null layout
153 // specifiy null Layout Line 154
154 super( null ); allows us to display
155 images anywhere on
Lines 165-168
156 instantiatePanels(); ElevatorView
157 placePanelsOnView();
158 initializeAudio();
159
160 // calculate distance Elevator travels
161 double floorDistance =
162 firstFloorPosition - secondFloorPosition;
163
164 // calculate time needed for travel
165 double time = ELEVATOR_TRAVEL_TIME / ANIMATION_DELAY;
166 Calculate velocity
167 // determine Elevator velocity (rate = distance / time) used by Elevator’s
168 elevatorVelocity = ( floorDistance + OFFSET ) / time; ImagePanel

 2003 Prentice Hall, Inc.


All rights reserved.
169 Outline
170 // start animation Thread
Starting Timer
171 startAnimation();
172 starts animation
ElevatorView.ja
173 } // end ElevatorView constructor
174
va
175 // instantiate all Panels (Floors, Elevator, etc.) ElevatorView
176 private void instantiatePanels() displays the elevator
177 { simulation model.
178 // instantiate ImagePanels representing Floors
179 firstFloorPanel = new ImagePanel( 0, floorImage ); Instantiate ImagePanels
180 secondFloorPanel = new ImagePanel( 0, floorImage );
Line 171
for Floors
181
182 // calculate first and second Floor positions Lines 179-180
183 firstFloorPosition =
184 VIEW_HEIGHT - firstFloorPanel.getHeight();
Line 191
185 secondFloorPosition =
186 ( int ) ( firstFloorPosition / 2 ) - OFFSET;
187 Lines 194-195
188 firstFloorPanel.setPosition( 0, firstFloorPosition );
189 secondFloorPanel.setPosition( 0, secondFloorPosition );
190
191 wallPanel = new ImagePanel( 0, wallImage );
Instantiate ImagePanel
192 for wall (not used in model)
193 // create and position ImagePanel for ElevatorShaft
194 elevatorShaftPanel =
Instantiate ImagePanel
195 new ImagePanel( 0, elevatorShaftImage ); for ElevatorShaft
196

 2003 Prentice Hall, Inc.


All rights reserved.
197 double xPosition = PERSON_TO_ELEVATOR_DISTANCE + OFFSET; Outline
198 double yPosition =
199 firstFloorPosition - elevatorShaftPanel.getHeight();
200 ElevatorView.ja
201 elevatorShaftPanel.setPosition( xPosition, yPosition );
202
va
203 // create and position ImagePanel for ceiling ElevatorView
Instantiate ImagePanel for
204 ceilingPanel = new ImagePanel( 0, ceilingImage ); displays the elevator
205
ceiling (not used in model)
simulation model.
206 yPosition = elevatorShaftPanel.getPosition().getY() -
207 ceilingPanel.getHeight();
208
Line 204
209 ceilingPanel.setPosition( xPosition, yPosition );
210 Line 212
211 // create and position MovingPanel for Elevator
Instantiate
212 elevatorPanel = new MovingPanel( 0, elevatorImage ); MovingPanel
Lines 219-220
213 for Elevator
214 yPosition = firstFloorPosition - elevatorPanel.getHeight();
215
216 elevatorPanel.setPosition( xPosition, yPosition );
217
218 // create and position first Floor Button
219 firstFloorButtonPanel =
Instantiate AnimatedPanel
220 new AnimatedPanel( 0, floorButtonFrames ); for Button on first Floor
221
222 xPosition = PERSON_TO_BUTTON_DISTANCE + 2 * OFFSET;
223 yPosition = firstFloorPosition - 5 * OFFSET;
224 firstFloorButtonPanel.setPosition( xPosition, yPosition );

 2003 Prentice Hall, Inc.


All rights reserved.
225 Outline
226 int floorButtonPressedFrameOrder[] = { 0, 1, 2 };
227 firstFloorButtonPanel.addFrameSequence( AnimatedPanels use
228 floorButtonPressedFrameOrder ); int arrays that ElevatorView.ja
determine
229 their image sequences
230 // create and position second Floor Button
va
231 secondFloorButtonPanel =
Instantiate AnimatedPanel
ElevatorView
232 new AnimatedPanel( 1, floorButtonFrames ); for Button on second Floor
displays the elevator
233 simulation model.
234 xPosition = PERSON_TO_BUTTON_DISTANCE + 2 * OFFSET;
235 yPosition = secondFloorPosition - 5 * OFFSET;
236 secondFloorButtonPanel.setPosition( xPosition, yPosition );
Lines 226-228
237
238 secondFloorButtonPanel.addFrameSequence( Lines 231-232
239 floorButtonPressedFrameOrder );
240 Instantiate AnimatedPanel
Lines 242-243
for Light on first Floor
241 // create and position Floor Lights
242 firstFloorLightPanel =
243 new AnimatedPanel( 0, firstFloorLightFrames ); Lines 250-251
244
245 xPosition = elevatorPanel.getLocation().x - 4 * OFFSET;
246 yPosition =
247 firstFloorButtonPanel.getLocation().y - 10 * OFFSET;
248 firstFloorLightPanel.setPosition( xPosition, yPosition );
249
250 secondFloorLightPanel =
Instantiate AnimatedPanel
251 new AnimatedPanel( 1, secondFloorLightFrames ); for Light on second Floor
252

 2003 Prentice Hall, Inc.


All rights reserved.
253 yPosition =
254 secondFloorButtonPanel.getLocation().y - 10 * OFFSET;
Instantiate
Outline
255 secondFloorLightPanel.setPosition( xPosition, yPosition );
256
AnimatedPanel for
257 // create and position Door AnimatedPanels Door inElevatorView.ja
Elevator
258 doorPanel = new AnimatedPanel( 0, doorFrames ); (Note: wevado not show
259 int doorOpenedFrameOrder[] = { 0, 1, 2, 3, 4 }; Doors ElevatorView
on Floors,
260 int doorClosedFrameOrder[] = { 4, 3, 2, 1, 0 };
261 doorPanel.addFrameSequence( doorOpenedFrameOrder );
becausedisplays
they would
the elevator
262 doorPanel.addFrameSequence( doorClosedFrameOrder ); obscure Person when
simulation model.
263 riding Elevator)
264 // determine where Door is located relative to Elevator
Line 258
265 yPosition =
266 elevatorPanel.getHeight() - doorPanel.getHeight();
267 Line 271
268 doorPanel.setPosition( 0, yPosition ); Instantiate AnimatedPanel
269 for Light inside Elevator
Line 275
270 // create and position Light AnimatedPanel
271 elevatorLightPanel = new AnimatedPanel( 0, lightFrames );
272 elevatorLightPanel.setPosition( OFFSET, 5 * OFFSET );
273
274 // create and position Bell AnimatedPanel
275 bellPanel = new AnimatedPanel( 0, bellFrames );
Instantiate AnimatedPanel
276 for Bell inside Elevator
277 yPosition = elevatorLightPanel.getPosition().getY() +
278 elevatorLightPanel.getHeight() + OFFSET;
279
280 bellPanel.setPosition( OFFSET, yPosition );
281 int bellRingAnimation[] = { 0, 1, 0, 2 };
282 bellPanel.addFrameSequence( bellRingAnimation );

 2003 Prentice Hall, Inc.


All rights reserved.
283
284 // create and position Elevator's Button AnimatedPanel Outline
285 elevatorButtonPanel = Instantiate AnimatedPanel
286 new AnimatedPanel( 0, elevatorButtonFrames ); for Button inside Elevator
287 ElevatorView.ja
288 yPosition = elevatorPanel.getHeight() - 6 * OFFSET; va
289 elevatorButtonPanel.setPosition( 10 * OFFSET, yPosition );
290
ElevatorView
291 int buttonPressedFrameOrder[] = { 0, 1, 2 }; displays the elevator
292 elevatorButtonPanel.addFrameSequence( simulation model.
293 buttonPressedFrameOrder );
294
Lines 285-286
Instantiate ArrayList to store
295 // create List to store Person AnimatedPanels
296 personAnimatedPanels = new ArrayList(); references to AnimatedPanel’s
297 associated withLine 296
Person’s
298 } // end method instantiatePanels
299 Lines 305-314
300 // place all Panels on ElevatorView
301 private void placePanelsOnView()
302 {
303 // add Panels to ElevatorView
304 add( firstFloorPanel );
305 add( secondFloorPanel );
306 add( ceilingPanel );
Add ImagePanels
307 add( elevatorPanel ); to ElevatorView
308 add( firstFloorButtonPanel );
309 add( secondFloorButtonPanel );
310 add( firstFloorLightPanel );
311 add( secondFloorLightPanel );
312 add( elevatorShaftPanel );
313 add( wallPanel );
 2003 Prentice Hall, Inc.
All rights reserved.
314 Outline
315 // add Panels to Elevator's MovingPanel
Add ImagePanels for
316 elevatorPanel.add( doorPanel );
317 elevatorPanel.add( elevatorLightPanel ); elevator’s door, light bell and
ElevatorView.ja
318 elevatorPanel.add( bellPanel ); button to the ImagePanel
va
319 elevatorPanel.add( elevatorButtonPanel ); associated with Elevator
320 ElevatorView
321 } // end method placePanelsOnView displays the elevator
322 simulation model.
323 // get sound effects and elevatorMusic
324 private void initializeAudio()
325 {
Lines 316-319
326 // create AudioClip sound effects from audio files SoundEffects object
327 SoundEffects sounds = new SoundEffects(); Line 327
creates AudioClips
328 sounds.setPathPrefix( "sounds/" );
that play sound clips
329
Lines 330-336
330 bellClip = sounds.getAudioClip( bellSound );
331 doorOpenClip = sounds.getAudioClip( doorOpenSound );
332 doorCloseClip = sounds.getAudioClip( doorCloseSound ); Use SoundEffects
333 elevatorClip = sounds.getAudioClip( elevatorSound ); object to obtain references
334 buttonClip = sounds.getAudioClip( buttonSound );
335 walkClip = sounds.getAudioClip( walkingSound );
to AudioClips
336 elevatorMusicClip = sounds.getAudioClip( elevatorMusicSound );
337
338 } // end method initializeAudio
339

 2003 Prentice Hall, Inc.


All rights reserved.
340 // starts animation by repeatedly drawing images to screen Outline
341 public void startAnimation()
342 {
343 if ( animationTimer == null ) { ElevatorView.ja
344 animationTimer = Method startAnimation starts
345 new javax.swing.Timer( ANIMATION_DELAY, this );
va animation
Timer, which starts
346 animationTimer.start(); ElevatorView
347 } displays the elevator
348 else simulation model.
349
350 if ( !animationTimer.isRunning() )
351 animationTimer.restart();
Lines 341-352
352 }
353 Lines 355-358
354 // stop animation
355 public void stopAnimation() Method stopAnimation stops
Lines
Timer, which stops 361-381
animation
356 {
357 animationTimer.stop();
358 } Lines 363-366
359
360 // update AnimatedPanels animation in response to Timer
361 public void actionPerformed( ActionEvent actionEvent )
362 {
363 elevatorPanel.animate(); Timer invokes method
364 actionPerformed every 50
365 firstFloorButtonPanel.animate(); Animate ImagePanels for
(ANIMATION_DELAY) milliseconds
366 secondFloorButtonPanel.animate(); Elevator and Floors
367

 2003 Prentice Hall, Inc.


All rights reserved.
368 Iterator iterator = getPersonAnimatedPanelsIterator(); Outline
369
370 while ( iterator.hasNext() ) {
371 ElevatorView.ja
372 // get Person's AnimatedPanel from Set
373 AnimatedPanel personPanel =
va
374 ( AnimatedPanel ) iterator.next(); ElevatorView
375 displays the elevator
376 personPanel.animate(); // update panel Animate ImagePanels for Persons
simulation model.
377 }
378
379 repaint(); // paint all Components
Lines 370-377
380
381 } // end method actionPerformed Line 388
382
383 private Iterator getPersonAnimatedPanelsIterator()
Lines 393-407
384 {
385 // obtain iterator from List
386 synchronized( personAnimatedPanels )
387 { Obtain the Iterator of the
388 return new ArrayList( personAnimatedPanels ).iterator(); ArrayList of (Person)
389 } AnimatedPanels
390 }
391
392 // stop sound clip of Person walking
393 private void stopWalkingSound()
Stop sound clip played by Elevator-
394 { View when a Person walks
395 // stop playing walking sound
396 walkClip.stop();

 2003 Prentice Hall, Inc.


All rights reserved.
397 Outline
398 Iterator iterator = getPersonAnimatedPanelsIterator();
399
400 // but if Person is still walking, then keep playing ElevatorView.ja
401 while ( iterator.hasNext() ) {
402 AnimatedPanel panel = ( AnimatedPanel ) iterator.next();
va
403 ElevatorView
404 if ( panel.getXVelocity() != 0 ) displays the elevator
405 walkClip.loop();
If a Person is still walking,
simulation model.
406 } continue the sound clip
407 } // end method stopWalkingSound
408
Lines 401-406
409 // returns Person AnimatedPanel with proper identifier
410 private AnimatedPanel getPersonPanel( PersonMoveEvent event ) Lines 410-428
411 {
412 Iterator iterator = getPersonAnimatedPanelsIterator();
413
414 while ( iterator.hasNext() ) {
Obtain AnimatedPanel
415 associated with Person that
416 // get next AnimatedPanel sent the PersonMoveEvent
417 AnimatedPanel personPanel =
418 ( AnimatedPanel ) iterator.next();
419
420 // return AnimatedPanel with identifier that matches
421 if ( personPanel.getID() == event.getID() )
422 return personPanel;
423 }
424

 2003 Prentice Hall, Inc.


All rights reserved.
425 // return null if no match with correct identifier Outline
426 return null;
427
428 } // end method getPersonPanel
Invoked when Elevator
has departed from Floor ElevatorView.ja
429
430 // invoked when Elevator has departed from Floor
va
431 public void elevatorDeparted( ElevatorMoveEvent moveEvent ) ElevatorView
432 { displays the elevator
433 String location = simulation model.
434 moveEvent.getLocation().getLocationName();
435
436 // determine if Person is on Elevator
Line 431
437 Iterator iterator = getPersonAnimatedPanelsIterator();
438 Lines 439-471
439 while ( iterator.hasNext() ) {
Determine whether Person
440 is on Elevator
441 AnimatedPanel personPanel =
442 ( AnimatedPanel ) iterator.next();
443
444 double yPosition = personPanel.getPosition().getY();
445 String panelLocation;
446
447 // determine on which Floor the Person entered
448 if ( yPosition > secondFloorPosition )
449 panelLocation = FIRST_FLOOR_NAME;
450 else
451 panelLocation = SECOND_FLOOR_NAME;
452

 2003 Prentice Hall, Inc.


All rights reserved.
453 int xPosition =
454 ( int ) personPanel.getPosition().getX();
Outline
455
456 // if Person is inside Elevator
457 if ( panelLocation.equals( location ) ElevatorView.ja
458 && xPosition > PERSON_TO_BUTTON_DISTANCE + OFFSET ) { va
459 ElevatorView
460 // remove Person AnimatedPanel from ElevatorView
displays the elevator
461 remove( personPanel );
462
simulation model.
463 // add Person AnimatedPanel to Elevator
464 elevatorPanel.add( personPanel, 1 ); Lines 457-470
465 personPanel.setLocation( 2 * OFFSET, 9 * OFFSET );
466 personPanel.setMoving( false );
Lines 474-479
If Person is inside Elevator,
467 personPanel.setAnimating( false );
468 personPanel.setVelocity( 0, 0 ); remove Person from Elevator-
469 personPanel.setCurrentFrame( 1 ); View and add Person to Elevator
470 }
471 } // end while loop
472
473 // determine Elevator velocity depending on Floor
474 if ( location.equals( FIRST_FLOOR_NAME ) )
475 elevatorPanel.setVelocity( 0, -elevatorVelocity );
476 else
Determine Elevator
477
478 if ( location.equals( SECOND_FLOOR_NAME ) )
velocity depending on Floor
479 elevatorPanel.setVelocity( 0, elevatorVelocity );
480

 2003 Prentice Hall, Inc.


All rights reserved.
481 // begin moving Elevator and play Elevator music
482 elevatorPanel.setMoving( true ); Outline
483
484 if ( elevatorClip != null )
Set Elevator to moving state, then
485 elevatorClip.play(); play sound effect andElevatorView.ja
music associated
486 va movement
with the Elevator’s
487 elevatorMusicClip.play();
488
ElevatorView
489 } // end method elevatorDeparted displays the elevator
490 simulation model.
491 // invoked when Elevator has arrived at destination Floor
492 public void elevatorArrived( ElevatorMoveEvent moveEvent ) Invoked
Lineswhen
482-487
493 { Elevator has
494 // stop Elevator and music arrived at Floor
495 elevatorPanel.setMoving( false ); Line 492
496 elevatorMusicClip.stop();
497 Lines 495-496
498 double xPosition = elevatorPanel.getPosition().getX();
Set Elevator to waiting state
499 double yPosition; and stop music associated with
500 the Elevator’sLines 502-509
movement
501 // set Elevator's position to either first or second Floor
502 if ( elevatorPanel.getYVelocity() < 0 )
503 yPosition =
504 secondFloorPosition - elevatorPanel.getHeight();
505 else
506 yPosition = Set Elevator’s y-
507 firstFloorPosition - elevatorPanel.getHeight();
508
coordinate to that of the
509 elevatorPanel.setPosition( xPosition, yPosition ); Floor on which the
510 Elevator arrived
511 } // end method elevatorArrived
 2003 Prentice Hall, Inc.
All rights reserved.
512
513 // invoked when Person has been created in model Invoked when user Outline
creates
514 public void personCreated( PersonMoveEvent personEvent ) Person in simulation
515 {
516 int personID = personEvent.getID(); ElevatorView.ja
517 Determine
va which
518 String floorLocation = PersonElevatorView
was created
519 personEvent.getLocation().getLocationName(); and on what Floor
520 displays the elevator
521 // create AnimatedPanel representing Person
Create AnimatedPanel simulation
to model.
522 AnimatedPanel personPanel =
523 new AnimatedPanel( personID, personFrames );
represent Person in view
Line 514
524
525 // determine where Person should be drawn initially
526 // negative xPosition ensures Person drawn offscreen Lines 516-519
527 double xPosition = - personPanel.getWidth();
528 double yPosition = 0; Position Person’s
Lines 522-523
529 AnimatedPanel outside
530 if ( floorLocation.equals( FIRST_FLOOR_NAME ) ) the view, Lines Person
so the 530-541
531 yPosition = firstFloorPosition +
does not suddenly “appear.”
532 ( firstFloorPanel.getHeight() / 2 );
533 else
534
535 if ( floorLocation.equals( SECOND_FLOOR_NAME ) )
536 yPosition = secondFloorPosition +
537 ( secondFloorPanel.getHeight() / 2 );
538
539 yPosition -= personPanel.getHeight();
540
541 personPanel.setPosition( xPosition, yPosition );

 2003 Prentice Hall, Inc.


All rights reserved.
542 Outline
543 // add some animations for each Person
544 int walkFrameOrder[] = { 1, 0, 1, 2 };
545 int pressButtonFrameOrder[] = { 1, 3, 3, 4, 4, 1 };
546 int walkAwayFrameOrder[] = { 6, 5, 6, 7 }; Add animationElevatorView.ja
sequences
547 personPanel.addFrameSequence( walkFrameOrder );
vapressing
(e.g., walking and
548 personPanel.addFrameSequence( pressButtonFrameOrder ); buttons) for theElevatorView
Person
549 personPanel.addFrameSequence( walkAwayFrameOrder ); displays the elevator
550 simulation model.
551 // have Person begin walking to Elevator
Set the Person’s
552 personPanel.playAnimation( 0 );
553 personPanel.setLoop( true );
AnimatedPanel to 544-549
Lines
554 personPanel.setAnimating( true ); its moving state (i.e.,
555 personPanel.setMoving( true ); walking to Elevator)Lines 552-555
556
557 // determine Person velocity
Lines 558-563
558 double time =
559 ( double ) ( TIME_TO_BUTTON / ANIMATION_DELAY );
560
561 double xDistance = PERSON_TO_BUTTON_DISTANCE -
562 2 * OFFSET + personPanel.getSize().width; Calculate Person’s velocity
563 double xVelocity = xDistance / time; and distance to Elevator
564
565 personPanel.setVelocity( xVelocity, 0 );
566 personPanel.setAnimationRate( 1 );
567
568 walkClip.loop(); // play sound clip of Person walking
569

 2003 Prentice Hall, Inc.


All rights reserved.
570 // store in personAnimatedPanels
571 synchronized( personAnimatedPanels ) Outline
572 { Add Person’s
573 personAnimatedPanels.add( personPanel );
AnimatedPanel
574 } ElevatorView.ja
575
to ElevatorView
va
576 add( personPanel, 0 );
577
ElevatorView
578 } // end method personCreated displays the elevator
579 simulation model.
580 // invoked when Person has arrived at Elevator
581 public void personArrived( PersonMoveEvent personEvent )
Invoked when Person
582 { has arrived atLine 573
Elevator
583 // find Panel associated with Person that issued event
584 AnimatedPanel panel = getPersonPanel( personEvent ); Line 581
585 Find AnimatedPanel
586 if ( panel != null ) { // if Person exists associated with Line
Person
584that
587 issued event
588 // Person stops at Floor Button
589 panel.setMoving( false );
Lines 589-592
590 panel.setAnimating( false );
Set Person’s Animated-
591 panel.setCurrentFrame( 1 ); Panel to waiting state
592 stopWalkingSound(); (waiting for at Elevator)
593
594 double xPosition = PERSON_TO_BUTTON_DISTANCE -
595 ( panel.getSize().width / 2 );
596 double yPosition = panel.getPosition().getY();
597
598 panel.setPosition( xPosition, yPosition );
599 }
600 } // end method personArrived
 2003 Prentice Hall, Inc.
All rights reserved.
Invoked when Person
601 Outline
is pressing Button
602 // invoked when Person has pressed Button
603 public void personPressedButton( PersonMoveEvent personEvent )
604 { ElevatorView.ja
605 // find Panel associated with Person that issued event
Find AnimatedPanel
va
606 AnimatedPanel panel = getPersonPanel( personEvent );
607 associated withElevatorView
Person that
608 if ( panel != null ) { // if Person exists issued event
displays the elevator
609 simulation model.
610 // Person stops walking and presses Button
Start animation of Person
611 panel.setLoop( false );
612 panel.playAnimation( 1 );
pressing ButtonLine 603
613
614 panel.setVelocity( 0, 0 ); Line 606
615 panel.setMoving( false );
616 panel.setAnimating( true );
Lines 611-612
617 stopWalkingSound();
618 }
619 } // end method personPressedButton Line 622
620
621 // invoked when Person has started to enter Elevator LinePerson
625
Invoked when
622 public void personEntered( PersonMoveEvent personEvent )
623 {
is entering Elevator
624 // find Panel associated with Person that issued event
Find AnimatedPanel
625 AnimatedPanel panel = getPersonPanel( personEvent );
626
associated with Person that
issued event

 2003 Prentice Hall, Inc.


All rights reserved.
627 if ( panel != null ) {
628 Outline
629 // determine velocity
630 double time = TIME_TO_ELEVATOR / ANIMATION_DELAY;
631 ElevatorView.ja
632 double distance = va
633 elevatorPanel.getPosition().getX() -
ElevatorView
634 panel.getPosition().getX() + 2 * OFFSET; Determine Person’s velocity
635 displays the elevator
when entering Elevator, then
636 panel.setVelocity( distance / time, -1.5 ); simulation model.
637
set Person’s Animated-
638 // Person starts walking Panel to moving state
Lines 627-642
639 panel.setMoving( true );
640 panel.playAnimation( 0 );
641 panel.setLoop( true ); Line 646
642 }
643 } // end method personEntered Line 649
644
645 // invoked when Person has departed from Elevator
Invoked when Person
Line 657
646 public void personDeparted( PersonMoveEvent personEvent)
647 { has exited Elevator
648 // find Panel associated with Person that issued event
649 AnimatedPanel panel = getPersonPanel( personEvent ); Find AnimatedPanel
650 associated with Person that
651 if ( panel != null ) { // if Person exists issued event
652
653 // determine velocity (in opposite direction)
654 double time = TIME_TO_BUTTON / ANIMATION_DELAY;
655 double xVelocity = - PERSON_TO_BUTTON_DISTANCE / time;
656 Set Person velocity to
657 panel.setVelocity( xVelocity, 0 ); the opposite of that when
the Person was  2003 Prentice Hall, Inc.
created
All rights reserved.
658 Outline
659 // remove Person from Elevator
660 elevatorPanel.remove( panel );
661 ElevatorView.ja
662 double xPosition =
663 PERSON_TO_ELEVATOR_DISTANCE + 3 * OFFSET;
va
664 double yPosition = 0; ElevatorView
665 displays the elevator
666 String floorLocation = simulation model.
667 personEvent.getLocation().getLocationName();
668
669 // determine Floor onto which Person exits
Lines 670-677
670 if ( floorLocation.equals( FIRST_FLOOR_NAME ) )
671 yPosition = firstFloorPosition + Set Person’sLiney-coordinate
684 to
672 ( firstFloorPanel.getHeight() / 2 ); that of the Floor on which the
673 else Elevator is located
674
675 if ( floorLocation.equals( SECOND_FLOOR_NAME ) )
676 yPosition = secondFloorPosition +
677 ( secondFloorPanel.getHeight() / 2 );
678
679 yPosition -= panel.getHeight();
680
681 panel.setPosition( xPosition, yPosition );
682
683 // add Person to ElevatorView Add Person’s AnimatedPanel
684 add( panel, 0 ); to ElevatorView
685

 2003 Prentice Hall, Inc.


All rights reserved.
686 // Person starts walking Outline
Set Person’s AnimatedPanel
687 panel.setMoving( true );
688 panel.setAnimating( true );
to moving state
689 panel.playAnimation( 2 ); ElevatorView.ja
690 panel.setLoop( true );
691 walkClip.loop();
va
692 } ElevatorView
693 } // end method PersonDeparted displays the elevator
694 simulation model.
695 // invoked when Person has exited simulation
Invoked when Person
696 public void personExited( PersonMoveEvent personEvent)
697 {
has exited simulation
Lines 687-691
698 // find Panel associated with Person that issued moveEvent
699 AnimatedPanel panel = getPersonPanel( personEvent ); Line 696
700
Find Panel associated with
701 if ( panel != null ) { // if Person exists Person that issued moveEvent
Line 699
702
703 panel.setMoving( false );
704 panel.setAnimating( false ); Line 709
705
706 // remove Person permanently and stop walking sound
707 synchronized( personAnimatedPanels )
708 { Remove Person’s
709 personAnimatedPanels.remove( panel ); AnimatedPanel
710 } from ElevatorView
711 remove( panel );
712 stopWalkingSound();
713 }
714 } // end method personExited

 2003 Prentice Hall, Inc.


All rights reserved.
715
716 // invoked when Door has opened in model Outline
717 public void doorOpened( DoorEvent doorEvent ) Invoked when Door has opened
718 {
719 // get DoorEvent Location ElevatorView.ja
720 String location = va
721 doorEvent.getLocation().getLocationName();
722
ElevatorView
723 // play animation of Door opening displays the elevator
724 doorPanel.playAnimation( 0 ); simulation
Play animation of Door opening model.
725 doorPanel.setAnimationRate( 2 );
726 doorPanel.setDisplayLastFrame( true );
Line 717
727
728 // play sound clip of Door opening
729 if ( doorOpenClip != null ) Lines 724-726
Play sound effect of Door opening
730 doorOpenClip.play();
731 Lines 729-730
732 } // end method doorOpened
733
734 // invoked when Door has closed in model
Line 739
735 public void doorClosed( DoorEvent doorEvent )
Invoked when Door has closed
736 { Lines 742-744
737 // get DoorEvent Location
738 String location =
739 doorEvent.getLocation().getLocationName();
740
741 // play animation of Door closing
742 doorPanel.playAnimation( 1 ); Play animation of Door closing
743 doorPanel.setAnimationRate( 2 );
744 doorPanel.setDisplayLastFrame( true );

 2003 Prentice Hall, Inc.


All rights reserved.
745 Outline
746 // play sound clip of Door closing
747 if ( doorCloseClip != null ) Play sound effect of Door closing
748 doorCloseClip.play(); ElevatorView.ja
749
750 } // end method doorClosed
va
751 ElevatorView
752 // invoked when Button has been pressed in model displays the elevator
753 public void buttonPressed( ButtonEvent buttonEvent )
Invoked when Button
simulation model.
754 { has been pressed
755 // get ButtonEvent Location
756 String location =
Lines 747-748
757 buttonEvent.getLocation().getLocationName(); Obtain Location where
758 Button wasLinepressed
753
759 // press Elevator Button if from Elevator If Button was pressed in
760 if ( location.equals( ELEVATOR_NAME ) ) {
761 elevatorButtonPanel.playAnimation( 0 );
Elevator,
Linesplay
756-757
762 elevatorButtonPanel.setDisplayLastFrame( true ); animation of Elevator’s
763 } Button being
Linespressed
760-763
764
765 // press Floor Button if from Floor Lines 768-771
766 else
767
768 if ( location.equals( FIRST_FLOOR_NAME ) ) { If Button was pressed on
769 firstFloorButtonPanel.playAnimation( 0 ); first Floor, play
770 firstFloorButtonPanel.setDisplayLastFrame( true ); animation of first Floor’s
771 } Button being pressed

 2003 Prentice Hall, Inc.


All rights reserved.
772 else Outline
773
774 if ( location.equals( SECOND_FLOOR_NAME ) ) {
775 secondFloorButtonPanel.playAnimation( 0 ); ElevatorView.ja
776 secondFloorButtonPanel.setDisplayLastFrame( true );
va
777 } If Button was pressed on
778 ElevatorView
second Floor, play
779 if ( buttonClip != null ) displays the elevator
780 buttonClip.play(); // play button press sound clip animation of second Floor’s
simulation model.
781 Button being pressed
782 } // end method buttonPressed
783
Lines 774-777
784 // invoked when Button has been reset in model
Invoked when Button
785 public void buttonReset( ButtonEvent buttonEvent ) Line 785
786 {
has been reset
787 // get ButtonEvent Location
Lines 788-789
Obtain Location where
788 String location =
789 buttonEvent.getLocation().getLocationName(); Button was reset
790 Lines 792-799
791 // reset Elevator Button if from Elevator
792 if ( location.equals( ELEVATOR_NAME ) ) {
793 If Button was reset in
794 // return to first frame if still animating
Elevator, play
795 if ( elevatorButtonPanel.isAnimating() )
796 elevatorButtonPanel.setDisplayLastFrame( false );
animation of Elevator’s
797 else Button being reset
798 elevatorButtonPanel.setCurrentFrame( 0 );
799 }

 2003 Prentice Hall, Inc.


All rights reserved.
800 Outline
801 // reset Floor Button if from Floor
802 else
803 ElevatorView.ja
804 if ( location.equals( FIRST_FLOOR_NAME ) ) {
805
va
806 // return to first frame if still animating
If Button was reset on
ElevatorView
807 if ( firstFloorButtonPanel.isAnimating() ) first Floor,
displaysplay
the elevator
808 firstFloorButtonPanel.setDisplayLastFrame( false ); animation of first Floor’s
simulation model.
809 Button being reset
810 else
811 firstFloorButtonPanel.setCurrentFrame( 0 );
Lines 804-812
812 }
813 else Lines 815-823
814
815 if ( location.equals( SECOND_FLOOR_NAME ) ) {
816
817 // return to first frame if still animating
If Button was reset on
818 if ( secondFloorButtonPanel.isAnimating() ) second Floor, play
819 secondFloorButtonPanel.setDisplayLastFrame( animation of second Floor’s
820 false ); Button being reset
821 else
822 secondFloorButtonPanel.setCurrentFrame( 0 );
823 }
824
825 } // end method buttonReset
826

 2003 Prentice Hall, Inc.


All rights reserved.
827 // invoked when Bell has rung in model Outline
828 public void bellRang( BellEvent bellEvent ) Invoked when Bell has rung
829 {
830 bellPanel.playAnimation( 0 ); // animate Bell ElevatorView.ja
831
832 if ( bellClip != null ) // play Bell sound clip
va
Play animation and sound
833 bellClip.play(); ElevatorView
effect of Bell ringing
834 } displays the elevator
835 simulation model.
836 // invoked when Light turned on in model
Invoked when Light
837 public void lightTurnedOn( LightEvent lightEvent )
838 {
has turned on 828
Line
839 // turn on Light in Elevator
840 elevatorLightPanel.setCurrentFrame( 1 ); Lines 830-833
841
842 String location = If Light was Lineilluminated
837
843 lightEvent.getLocation().getLocationName(); on first Floor, play
844
845 // turn on Light on either first or second Floor
first Floor’s
animation ofLines 846-847
846 if ( location.equals( FIRST_FLOOR_NAME ) ) Light being turned on
847 firstFloorLightPanel.setCurrentFrame( 1 ); Lines 851-852
848
849 else
850 If Light was illuminated on
851 if ( location.equals( SECOND_FLOOR_NAME ) ) second Floor, play animation
852 secondFloorLightPanel.setCurrentFrame( 1 ); of second Floor’s Light
853 being turned on
854 } // end method lightTurnedOn
855

 2003 Prentice Hall, Inc.


All rights reserved.
856 // invoked when Light turned off in model Invoked when Light Outline
857 public void lightTurnedOff( LightEvent lightEvent )
858 {
has turned off
859 // turn off Light in Elevator ElevatorView.ja
860 elevatorLightPanel.setCurrentFrame( 0 );
861
va
862 String location = ElevatorView
If Light was turned off
863 lightEvent.getLocation().getLocationName(); displays the elevator
864
first Floor, play animation
simulation model.
865 // turn off Light on either first or second Floor of first Floor’s Light
866 if ( location.equals( FIRST_FLOOR_NAME ) ) being turned off
867 firstFloorLightPanel.setCurrentFrame( 0 );
Line 857
868
869 else Lines 866-867
870
If Light was turned off on
871 if ( location.equals( SECOND_FLOOR_NAME ) ) second Floor, play animation
Lines 871-872
872 secondFloorLightPanel.setCurrentFrame( 0 ); of second Floor’s Light
873 being turned off
874 } // end method lightTurnedOff Lines 877-880
875
876 // return preferred size of ElevatorView
877 public Dimension getPreferredSize()
878 { Set ElevatorView’s preferred
879 return new Dimension( VIEW_WIDTH, VIEW_HEIGHT ); size to VIEW_WIDTH and
880 } VIEW_HEIGHT
881

 2003 Prentice Hall, Inc.


All rights reserved.
882 // return minimum size of ElevatorView Outline
883 public Dimension getMinimumSize()
884 {
885 return getPreferredSize(); minimum
ElevatorView.ja
Set ElevatorView’s
886 }
887
va sizes to
and maximum
888 // return maximum size of ElevatorView VIEW_WIDTH andElevatorView
VIEW_HEIGHT
889 public Dimension getMaximumSize() displays the elevator
890 { simulation model.
891 return getPreferredSize();
892 }
893 }
Lines 883-892

 2003 Prentice Hall, Inc.


All rights reserved.
F.2 Class Objects

• ImagePanel
– Used for objects that are stationary in model
• e.g., Floor, ElevatorShaft
• MovingPanel
– Used for objects that “move” in model
• e.g., Elevator
• AnimatedPanel
– Used for objects that “animate” in model
• e.g., Person, Door, Button, Bell, Light

 2003 Prentice Hall, Inc. All rights reserved.


F.2 Class Objects (cont.)

The object (in model) is represented by the object of Class...


of Class... (in view)...
Floor firstFloorPanel
ImagePanel
secondFloorPanel
ImagePanel
ElevatorShaft elevatorShaftPanel
ImagePanel
Elevator elevatorPanel MovingPanel
Button (on Floor) firstFloorButtonPanel
AnimatedPanel
secondFloorButtonPanel
AnimatedPanel
Button (in Elevator) elevatorButtonPanel
AnimatedPanel
Bell bellPanel AnimatedPanel
Light firstFloorLightPanel
AnimatedPanel
secondFloorLightPanel
AnimatedPanel
Door (in Elevator) doorPanel AnimatedPanel
Door (on Floor) <not represented>
<not represented>
Person personAnimatedPanels
List (of
AnimatedPanels)
Fig. F.2 Objects in the ElevatorView representing objects in the model.

 2003 Prentice Hall, Inc. All rights reserved.


F.2 Class Objects (cont.)

The object (in is represented by the object of Class...


model) of (in view)...
Class...
<not represented> elevatorLightPanel AnimatedPanel
<not represented> ceilingPanel ImagePanel
<not represented> wallPanel ImagePanel
Fig. F.3 Objects in the ElevatorView not represented in the model.

 2003 Prentice Hall, Inc. All rights reserved.


F.3 Class Constants

• Constants specify such information as:


– Initial placement of objects in ElevatorView
– Rate at which ElevatorView redraws screen
– Names of image files used by ImagePanels
– Names of sound files used by SoundEffects
– Distances in pixels the ImagePanels representing
Elevator and Person must travel
– Times needed to travel these distances

 2003 Prentice Hall, Inc. All rights reserved.


F.4 Class Constructor

• ElevatorView constructor’s responsibilities:


– Instantiate ImagePanels
– Add all ImagePanels to ElevatorView
– Initialize audio objects
– Compute initial velocity and distance traveled
– Start animation Timer

 2003 Prentice Hall, Inc. All rights reserved.


F.4 Class Constructor (cont.)
firstFloorButtonPanel : AnimatedPanel
firstFloorPanel : ImagePanel
secondFloorButtonPanel : AnimatedPanel
secondFloorPanel : ImagePanel
firstFloorLightPanel : AnimatedPanel
elevatorShaftPanel : ImagePanel
secondFloorLightPanel : AnimatedPanel
ceilingPanel : ImagePanel

wallPanel : ImagePanel

elevatorPanel : MovingPanel : ElevatorView

bellClip : AudioClip

doorOpenClip : AudioClip

lightPanel : AnimatedPanel doorCloseClip : AudioClip


: SoundEffects
bellPanel : AnimatedPanel elevatorClip : AudioClip

doorPanel : AnimatedPanel buttonClip : AudioClip

walkClip : AudioClip
elevatorButtonPanel : AnimatedPanel

Fig F.4 Object diagram for the ElevatorView after initialization.

 2003 Prentice Hall, Inc. All rights reserved.


F.5 Event Handling

• Event Handling in the view


– ElevatorView implements interface Elevator-
SimulationListener
• ElevatorView implements all interfaces
– ElevatorSimulation sends events to
ElevatorView
• ElevatorCaseStudy registers ElevatorView for
events from ElevatorSimulation

 2003 Prentice Hall, Inc. All rights reserved.


F.5.1 ElevatorMoveEvent types

• ElevatorSimulation
– Sends ElevatorMoveEvent when Elevator departed
or arrived in the model
– Invokes method elevatorDeparted when Elevator
departed from Floor
– Invokes method elevatorArrived when Elevator
arrived at Floor

 2003 Prentice Hall, Inc. All rights reserved.


F.5.2 PersonMoveEvent types

• ElevatorSimulation
– Sends PersonMoveEvent when Person performes actions
– Invokes method personCreated when model instantiates new
Person
– Invokes method personArrived when Person arrives at
Elevator
– Invokes method personPressedButton when Person presses
Button
– Invokes method personEntered when Person enters
Elevator
– Invokes method personDeparted when Person exits
Elevator
– Invokes method personExited when Person exits simulation

 2003 Prentice Hall, Inc. All rights reserved.


F.5.3 DoorEvent types

• ElevatorSimulation
– Sends DoorEvent when Door opened or closed in the
model
– Invokes method doorOpened when Door opened
– Invokes method doorClosed when Door closed

 2003 Prentice Hall, Inc. All rights reserved.


F.5.4 ButtonEvent types

• ElevatorSimulation
– Sends ButtonEvent when Button pressed or reset in
the model
– Invokes method buttonPressed when Button pressed
– Invokes method buttonReset when Button reset

 2003 Prentice Hall, Inc. All rights reserved.


F.5.5 BellEvent types

• ElevatorSimulation
– Sends BellEvent when Bell rung
• Invoking method bellRang

 2003 Prentice Hall, Inc. All rights reserved.


F.5.6 LightEvent types

• ElevatorSimulation
– Sends LightEvent when Light changed state in the
model
– Invokes method lightTurnedOn when Light turned on
– Invokes method lightTurnedOff when Light turned
off

 2003 Prentice Hall, Inc. All rights reserved.


F.6 Artifacts Revisited

• Component Diagram for view


– Package view contains six artifacts
• ElevatorView.java
– Aggregates (imports) packages images, sounds,
events
• ImagePanel.java
• MovingPanel.java
• AnimatedPanel.java
• ElevatorMusic.java
• SoundEffects.java

 2003 Prentice Hall, Inc. All rights reserved.


F.6 Component Diagrams Revisited (cont.)
view

<<imports>> <<file>>
<<imports>>
ElevatorView.java

<<imports>>

<<file>> <<file>>

ImagePanel.java MovingPanel.java

<<file>> <<file>>

AnimatedPanel.java SoundEffects.java

images sounds 1 event


1 1

Fig F.5 Component diagram for package view.

 2003 Prentice Hall, Inc. All rights reserved.


F.7 Conclusion

• OOD/UML case study


– Implement object-oriented system designs generated by
UML
– Using Java GUI, graphics and sound capabilities

 2003 Prentice Hall, Inc. All rights reserved.

You might also like