Question: In this assignment you will be using inheritance to create shapes. There will be circles, rectangles, and triangles with a base class of Shape. The

In this assignment you will be using inheritance to create shapes. There will be circles, rectangles, and triangles with a base class of Shape.
The Shape class:
- The Shape class shall have an id
- The Shape class shall populate the id with a static variable
- The Shape class shall have a getId() function that returns a copy of the id
- The Shape class shall have two pure virtual functions, calculateArea() and calculatePerimeter() that return doubles.
Rectangle will have a parameter constructor with width and height.
Triangle will have a parameter constructor with three doubles, one for each side of the triangle
Circle will have a parameter constructor with a double for a radius.
The Rectangle, Triangle, and Circle classes shall all override the calculateArea and calculatePerimeter functions.
To calculate area and perimeter of a circle, just use 3.14 for pi.
To calculate the area of a triangle, use sqrt(S *(S-a)*(S-b)*(S-c)) where S = perimeter /2;
With a triangle, make sure that the values passed in create a valid triangle (where two lengths are not bigger than the third). If it is invalid, print out
"Invalid Triangle" without the quotes, just return 0 in the calculate functions.
Only commit the CMakeLists.txt and the source code. Do not commit any auto generated files.
The files are
Circle.cpp
Circle.hpp
Rectangle.cpp
Rectangle.hpp
Shape.cpp
Shape.hpp
Triangle.cpp
Triangle.hpp
main.cpp
the answer 1-4 should be
0
1
2
3
4
5
6
7
8
9
3.14
6.28
314
62.8
0
0
11.399
21
Invalid Triangle
0
0
11.399
21
50
30
0
10
4
8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!