Java Reference
In-Depth Information
Display 12.3
Some Details of a UML Class Hierarchy
Person
−
name: String
+ setName(String newName):
void
+ getName(): String
+ toString(): String
+ sameName(Person otherPerson)):
boolean
Student
−
studentNumber:
int
+ set(String newName,
int
newStudentNumber):
void
+ getStudentNumber():
int
+ setStudentNumber(
int
newStudentNumber):
void
+ toString(): String
+ equals(Object otherObject):
boolean
More UML
This is just a hint of what UML is all about. If you are interested in learning more,
consult one of the many available references on UML.
Self-Test Exercises
1. Draw a class diagram for a class whose objects represent circles. Use Display 12.1 as
a model.
2. Suppose
. Based on the inheritance dia-
gram in Display 12.3, where will you find the definition of the method
is an object of the class
aStudent
Student
sameName
used in the following invocation, which compares
and another object
aStudent
named
? Explain your answer.
someStudent
Student someStudent =
new
Student("Joe Student", 7777);
if
(aStudent.sameName(someStudent))
System.out.println("wow");