Stage 3: Another Abstract class
Stage 3: Another Abstract class
Highlights:
The fly method needs to be better provisioned to accommodate future birds without repeating the code.
A new class called "bird" is introduced to model a hierarchy where all birds inherit from "animal".
The bird class has a constructor that accepts the name of the bird and passes it to the parent constructor.
The bird class is marked as abstract, as the climb method is also an abstract concept like animal.
Multi-level inheritance is used, with the animal class inherited by the bird class, which is inherited by the parrot class.
The climb contract is specified in the animal and concretely implemented in the parrot.
The fly method is only in the bird class, so any bird can inherit it, and repetition is avoided.
Animal.cs
No change!
Bird.cs
Cat.cs
No change!
Dog.cs
No change!
Parrot.cs
Program.cs
No change!
Last updated