For this project, you will implement a Geometric Shapes area and perimeter calculator, using the object-oriented design, diagramed below.
Shape
Method
Function
virtual float area()
declaration of virtual function to calculate and return area of shape (not implemented).
declaration of virtual function to calculate and return perimeterof shape (not implemented).
toName()
virtual function to return name of Class.
Circle, Rectangle, Triangle Classes
float area()
float perimeter()
Calculates and returns perimeter for Shape
string toName()
Returns className for the derived class. Returns "Circle", "Rectangle", "Triangle", etc.
Implementation Instructions:
// Use Heron's formula to calculate area:// A = SquareRoot(s * (s - a) * (s - b) * (s - c))// where s = (a + b + c) / 2, or 1/2 of the perimeter of the trianglefloat area() {float s = (a + b + c) / 2;return sqrt(s * (s - a) * (s - b) * (s - c));}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here