Solution Review: Implement and Override the Method
This review provides a detailed analysis on how to solve the 'Implement and Override the Method' challenge.
We'll cover the following...
Solution
Press + to interact
// Base Classclass Shape {public Shape() {} // Default Constructor// Getter Functionpublic virtual double ClacArea() {return 0;}}// Derived Classclass Circle : Shape {private double _radius;public Circle(double radius) { // Constructorthis._radius = radius;}// Overridden CalcArea() method which returns the area of Rectanglepublic override double ClacArea() {return (this._radius * this._radius) * 3.14;}}class Demo {public static void Main(string[] args) {Shape circle = new Circle(2);Console.WriteLine(circle.ClacArea());}}
Explanation
The ...