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 aStudent is an object of the class Student . Based on the inheritance
diagram in Display 12.3, where will you find the definition of the method
sameName used in the following invocation, which compares aStudent and
another object named someStudent ? Explain your answer.
Student someStudent =
new Student("Joe Student", 7777);
if (aStudent.sameName(someStudent))
System.out.println("wow");
 
 
Search WWH ::




Custom Search