Designing with Abstract Classes and Interfaces
an Example in Java |
Prof. David Bernstein
|
Computer Science Department |
bernstdh@jmu.edu |
String
representations
String
representations
-- Initializeable
Increaseable
Initializeable
in Weight
Initializeable
in Fraction
Increaseable
in Weight
Increaseable
in Fraction
Operand
objectsOperand
objectsWeight
object can take many forms
as a result of the fact that it implements several
interfaces (Increaseable
,
Initializeable
) and as a result of the fact that
it implicitly extends Object
(e.g., the
toString()
method)
Fraction
object can take many forms
as a result of the fact that it implements several
interfaces (Increaseable
,
Initializeable
) and as a result of the fact that
it implicitly extends Object
(e.g., the
toString()
method)
AddingMachine
can operate on any
object that is both Initializeable
and
Increaseable