Java Reference
In-Depth Information
CommunityMember
Employee
Student
Alumnus
Faculty
Staff
Administrator
Teacher
Fig. 9.2 | Inheritance hierarchy UML class diagram for university CommunityMember s.
Each arrow in the hierarchy represents an is-a relationship. As we follow the arrows
upward in this class hierarchy, we can state, for example, that “an Employee is a
CommunityMember ” and “a Teacher is a Faculty member.” CommunityMember is the direct
superclass of Employee , Student and Alumnus and is an indirect superclass of all the other
classes in the diagram. Starting from the bottom, you can follow the arrows and apply the
is-a relationship up to the topmost superclass. For example, an Administrator is a Fac-
ulty member, is an Employee , is a CommunityMember and, of course, is an Object .
Shape Hierarchy
Now consider the Shape inheritance hierarchy in Fig. 9.3. This hierarchy begins with su-
perclass Shape , which is extended by subclasses TwoDimensionalShape and ThreeDim-
ensionalShape Shape s are either TwoDimensionalShape s or ThreeDimensionalShape s.
The third level of this hierarchy contains specific types of TwoDimensionalShape s and
ThreeDimensionalShape s. As in Fig. 9.2, we can follow the arrows from the bottom of the
diagram to the topmost superclass in this class hierarchy to identify several is-a relation-
ships. For example, a Triangle is a TwoDimensionalShape and is a Shape , while a Sphere
is a ThreeDimensionalShape and is a Shape . This hierarchy could contain many other
classes. For example, ellipses and trapezoids also are TwoDimensionalShape s.
Shape
TwoDimensionalShape
ThreeDimensionalShape
Circle
Square
Triangle
Sphere
Cube
Tetrahedron
Fig. 9.3 | Inheritance hierarchy UML class diagram for Shape s.
 
 
Search WWH ::




Custom Search