![]() |
![]() |
![]() |
![]() |
![]() |
|
To detect and report such errors, you first
must define a class predicate, isWeight.
Most magnitudes are not weight instances, so you define isWeight
for the Magnitude class to answer false:
Magnitude method definition instance isWeight ^ false
On the other hand, Weight instances are Weight instances, so
you define isWeight for the Weight class to answer true:
Weight method definition instance isWeight ^ true
Thus, as you can see from the following diagram, one isWeight method
overrides the other exactly for instances of the Weight class, but not
for instances of other classes:
Object
|
*-*------------*--
| |
Collection Magnitude <-- isWeight method answers false
| |
| | isWeight method answers true
| | |
*-*-----*-- *-*-----*------------*-- |
| | | | | |
Bag Set Number Time Weight <-----*