Make a base class for a Polygon

The private members

  • numOfSides : int
  • sides[ ]: int // listed in clockwise order , MAX sides is 100

The attributes

  • + Polyon(numSides:int) // default is 0
  • + set(sideNum: int, value:int) : void// ensures no negative side values
  • + get (sideNum:int):int // returns the value of sides[sideNum]
  • + perimeter(): int virtual// returns the perimeter of the polygon
  • + area(): double virtual //returns the area of the polygon

Make a class for Rectangle derived from Polygon

The attributes

  • + Rectangle()// class Polygon(4);
  • + area() // appropriately
  • + perimeter()() // appropriately

Make a class for Square derived from Rectangle

The attributes

  • + Square()// appropriately
  • + area() // appropriately
  • + perimeter() // appropriately

Make a class for RightTri derived from Polygon

The attributes

  • + RightTri()// class Polygon(3); //. Assumes the order side, side, hypotenus
  • + area() // appropriately
  • + perimeter() // appropriately

Make a class for RectSolid derived from Rectangle

The members

  • -height: int

The attributes

  • + volume ()// returns the volume

In your main

  • Make a an array of pointers to Polygon and add an instance Of a rectangle with sides of length 4 and 10
  • A square with sides of length 5
  • A right triangle with sides 3, 4 and 5
  • A rectangular solid with sides of length 6 and 3 and height 5.
  • Use the array to have each shape print out its area perimeter , as well As the rectangular solid print out its volume.
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.