Skip to content

4.4 Inheritance: the Rectangle derived class

  1. Modify the Rectangle class so that it also becomes a derived class of Shape:

    • Add : Shape;
    • Remove the attributes LimitValueForBigShape and _color;
    • Modify the all-args constructor: call base(color) and remove this._color = color;
    • Adjust the constructor that passes the default value for color;
    • Override the methods CalculatePerimeter() and CalculateArea();
    • Remove the DescribeSize() method;
    • Remove the getter and setter for color.
  2. Uncomment the code about the rectangle and run your program. Your output is the same as in 3.5 The Rectangle class.