Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this project. Create (define and implement) a base class Shape classes that will inherit this class called Box, Rectangle, Circle, and

I need help with this project.

Create (define and implement) a base class Shape classes that will inherit this class called Box, Rectangle, Circle, and Triangle

Description:

Programming Specifications:

You will have a base class of Shape which will have an area and perimeter of type double. You must also create acceptable Gets and Sets for the private data items. All of the other classes will inherit this class.

You will have a class Square which will have just one length of type double. You should create acceptable Gets and Sets for the one data type. This class will inherit the base class

You will have a class Circle which will have just one length of type double which will be the radius. You should create acceptable Gets and Sets for the one data type. This class will inherit the base class

You will have a class Rectangle which will have two lengths of type double. You should create acceptable Gets and Sets for the two data types. This class will inherit the base class

You will have a class Triangle which will have three lengths of type double. You should create acceptable Gets and Sets for the two data types. This class will inherit the base class

You will have one virtual Member Function for all of the classes (Square, Rectangle, Circle, and Triangle) which will be called PrintData() which will print the details of the shape. All will have the area and perimeter but Circle will have a radius, Square will have one side, Rectangle will have two, and the Triangle will have three.

You should have two constructors for each class. A default constructor and one that accepts all of the private data items.

All sizes should be positive double floating point numbers at or above 1.00. There is no maximum size. If a size is entered less than 1.00 it should default to 1.00.

Write your own main routine to test your class. The test case should encompass using both constructors for each class, ensuring default values are properly used, and calling each method at least once.

Deliverables:

Tar file containing:

shape.h, shape.cpp

square.h, square.cpp

rectangle.h, rectangle.cpp

circle.h circle.cpp

triangle.h, triangle.cpp

main.cpp

makefile

Required Algorithms

Square Perimeter:

4 * side.

Square Area:

side*side

Rectangle Perimeter:

Side1*2 + Side2*2

Rectangle Area:

Side1 * Side2

Circle Area:

Pi * Radius*Radius

Circle Perimeter:

Pi * 2*Radiuis

Triangle Area:

Assume we know three sides (Side1, Side2, Side3) then the area based on Herons formula which gives the area in terms of the three sides of the triangle. First calculate s which is (Side1 + Side2 + Side3)/2. Then obtain the square root of the absolute value of following formula: s*(s Side1)*(s Side2)*(s Side3).

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

1. Explain the stage of corporate globalization.

Answered: 1 week ago