Create an abstract Animal
class that has private members weight and name, and abstract
methods Speak( )
, Move( )
, and ToString( )
. Derive from Animal
a Cat
and Dog
class that override the methods
appropriately. Create an Animal
array, populate it with Dogs
and Cats
, and then call each
member’s overridden virtual method.
Replace the array in Exercise 14-1 with a List
. Sort the animals by size. You can
simplify by just calling ToString( )
before and after the sort. Remember that you’ll need
to implement IComparable
.
Replace the list from Exercise 14-2 with both a Stack
and a Queue
, and see the difference in the
order in which the animals are returned.
Rewrite Exercise 14-2 to allow Animals
to be sorted either by weight or
alphabetically by name.