Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

4-5 How will MIS help my career?

Answered: 1 week ago

Question

2. Show the trainees how to do it without saying anything.

Answered: 1 week ago