Question: In this assignment, you are going to use classes to solve a given problem. Think of the solution from an Object Oriented point of view

In this assignment, you are going to use classes to solve a given problem. Think of the solution from an Object Oriented point of view where you are designing classes that communicate with each other to achieve a specific task, which would be the solution to the given problem).
Assignment Problem
A company wants to be able to display different mathematical shapes on the screen. Some of the shapes they are looking for are listed below:
A diamond
A triangle
A circle
A rhombus
The functionality of each shape is defined in a class. Each class contains the following functions:
DisplayShape(): This function displays the shape for that class
DisplayArea(): This function displays the area of that class
All classes you create need to inherit the following abstract class:
class Shape
{
public:
virtual void DisplayShape()=0;
virtual void DisplayArea()=0;
};
Feel free to add whatever you want to the class you declare (functions or attributes), but you may not modify the Shape class.
The Task
From the list above, select 2 shapes and create a class for each shape. Make sure in your class, you provide a way to set the member variables, which can be done in the constructor or by creating setter functions. Use the main() function to test your code by creating objects/instances for each shape you decide to program. Make sure your main test both DisplayShape and DisplayArea functions.
Hint
If you were to create a Rectangle class that would use the Shape abstract class, you would have something similar to the following:
class Rectangle
{
public:
void DisplayShape();
void DisplayArea();
};
void Rectangle::DisplayShape()
{
}
void Rectangle::DisplayArea()
{
}
void main()
{
Rectangle R;
R.DisplayRectangle();
R.DisplayArea();
}

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!