Imagine that the aquarium in the Aquarium Lab Series could hold more than just fish. We could create a simple superclass,
AquariumObject
, that implements the following methods:
int id()
: get the object's IDvoid act()
: does nothing, but can be redefined in subclasses to act/move in whatever way is appropriate for the object- possibly other methods, such as
toString
Subclasses of
AquariumObject
might include:
AquaFish
Crab
,Seahorse
,Shrimp
: each would move differently- (Large municipal aquarium):
Whales
,Dolphins
,Penguins
Coral
,Sea Grasses
,Kelp
Rocks
(might just inherit the do-nothingmove
method)