Question: Design and Implementation of a C++ class A Regular Octagon is a two-dimensional geometric shape that has 8 equal-length sides. For this question you will
Design and Implementation of a C++ class
A Regular Octagon is a two-dimensional geometric shape that has 8 equal-length sides. For this question you will be finding the surface area and perimeter of a Regular Octagon. You will need the following equations to calculate these two values:
Surface Area = two times (one plus the square root of two) times the length of a side squared.
or 2 (1 + 2) a2
The cmath library function double sqrt(double) should be used to calculate the square root.
Perimeter = eight times the length of the side (a)
or 8(a)
Note: Variable a in the above equation is the length of one of the sides of a Regular Octagon.
Design and implement the Octagon class based on the following class specification:
By default this class will have a side length of 1, otherwise a side can be specified in a constructor.
There should be a setter for all private data members
There should be a getter for all private data members.
There should be a function to return the surface area of the octagon.
There should be a function to return the perimeter of the octagon.
There should be a print function to print all parameters including perimeter, surface area, and side length.
Overload cout to display the same parameters as the print function
Overload cin to allow you to input the side length using cin
Overload the not equals operator to check to see if two octagons do not have the same side length
Overload the plus operator to add two octagon objects (essentially add the two side lengths together) to create a new object.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
