26.07.2013 Views

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 3 Introduction <strong>to</strong> <strong>Java</strong> Applets 139<br />

Resets<br />

FloorBut<strong>to</strong>n<br />

Fig. Fig. 3.21 3.21 Class diagram showing associations among classes.<br />

Symbol Meaning<br />

0 None.<br />

1 One.<br />

m An integer value.<br />

0..1 Zero or one.<br />

m, n m or n<br />

m..n At least m, but not more than n.<br />

* Zero or more.<br />

0..* Zero or more<br />

1..* One or more<br />

Fig. Fig. 3.22 3.22 Multiplicity types.<br />

2<br />

Eleva<strong>to</strong>rShaft<br />

1 1<br />

2 Requests 1<br />

Eleva<strong>to</strong>r<br />

Figure 3.23 shows the complete class diagram for the eleva<strong>to</strong>r model. We model all<br />

classes that we created, as well as the associations between these classes. [Note: In Chapter<br />

9, we expand our class diagram by using the object-oriented concept of inheritance.]<br />

Class Eleva<strong>to</strong>rModel is represented near the <strong>to</strong>p of the diagram and aggregates one<br />

object of class Eleva<strong>to</strong>rShaft and two objects of class Floor. The Eleva<strong>to</strong>r-<br />

Shaft class is an aggregation of one object of class Eleva<strong>to</strong>r and two objects each of<br />

classes Light, FloorDoor and FloorBut<strong>to</strong>n. (Notice the two-<strong>to</strong>-one relationships<br />

between each of these classes and Eleva<strong>to</strong>rShaft.) Class Eleva<strong>to</strong>r is an aggregation<br />

of classes Eleva<strong>to</strong>rDoor, Eleva<strong>to</strong>rBut<strong>to</strong>n and Bell. Class Person has associations<br />

with both FloorBut<strong>to</strong>n and Eleva<strong>to</strong>rBut<strong>to</strong>n (and other classes, as we will<br />

soon see). The association name Presses and the name-direction arrowheads indicate<br />

that the object of class Person presses these but<strong>to</strong>ns. The object of class Person also<br />

rides the object of class Eleva<strong>to</strong>r and walks across the object of class Floor. The name<br />

Requests indicates that an object of class FloorBut<strong>to</strong>n requests the object of class<br />

Eleva<strong>to</strong>r. The name Signals <strong>to</strong> move indicates that the object of class Eleva<strong>to</strong>r-<br />

But<strong>to</strong>n signals the object of class Eleva<strong>to</strong>r <strong>to</strong> move <strong>to</strong> the other floor. The diagram<br />

indicates many other associations, as well.<br />

© Copyright 1992–2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01<br />

1<br />

Signals<br />

arrival

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!