Create an application named Shapes Demo that creates several objects that descend from an abstract class called GeometricFigure. Each GeometricFigure includes a height, a width, and an area. Provide get and set accessors for each field except area; the area is computed and is read only. Include an abstract method called ComputeArea() that computes the area of the GeometricFigure. Create three additional classes:

  • A rectangle is a GeometricFigure whose area is determined by multiplying width by height.
  • A square is a Rectangle in which the width and height are the same. Provide a constructor that accepts both height and width, forcing them to be equal if they are not. Provide a second constructor that accepts just one dimension and uses it for both height and width. The Square class uses the Rectangles ComputeArea() method.
  • A Triangle is a GeometricFigure whose area is determined by multiplying the width by half and the height.

In the ShapesDemo class, after each object is created, pass it to a method that accepts a GeometricFigure argument in which the figures data is displayed. Change some dimensions of some of the figures, and pass each to the display method again.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.