Stage 2: Abstract method
Stage 2: Abstract method
Highlights:
This stage shows how to adhere to the dry principle and eliminate repetitions in a program.
A common animal class is created to push all commonalities upward and remove them in individual child classes.
Polymorphism is used to deal with similar but not same behaviors.
An abstract method called "climb" is created as a contract that all other children of the animal should follow.
Child classes are required to override the climb method to implement it.
This implementation of polymorphism makes the code more flexible, extensible, and maintainable.
The program's output remains the same, and there are no errors.
Animal.cs
Cat.cs
Dog.cs
Parrot.cs
Program.cs
No change!
Last updated