Stage 1: Inheritance
Stage 1: Inheritance
Highlights:
The previous stage implemented the animal's game but had a lot of repetitions violating the "do not repeat yourself" principle.
The "eat" function was the same in all animals, so it was removed from each animal and put in a parent "animal" class.
The "name" attribute was also made common to all animals in the "animal" class.
The program still had errors because the animals needed to inherit from the "animal" class and call its constructor.
The climb behavior is different for each animal, so it cannot be put in the "animal" class.
The next stage will cover removing similar but not same behaviors.
Animal.cs
Cat.cs
Dog.cs
Parrot.cs
Program.cs
No change!
Last updated