Programming and Problem Solving with Java

(やまだぃちぅ) #1

(^328) | Inheritance, Polymorphism, and Scope


7.2 Inheritance and the Object-Oriented Design Process


Now let’s consider how a class hierarchy originates in the CRC card design process. At the
end of the filtering phase, we sometimes discover that several classes are similar. For example,
in the address book example of Chapter 6, our filtered list of classes included Address and
Work Address. Let’s look at the CRC cards for some different address objects.

Class Name: WorkAddress Superclass: Subclasses:


Responsibilities Collaborations
Create itself (name, company, street, city,
state, ZIP code)

Name


Know its name Name
return String

return String


None


None
return String

return String


return String


return String


Know its company


None


Know its street


Know its city


Know its state None


Know its ZIP code None

Free download pdf