Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

More Books

Students also viewed these Databases questions

Question

Would you investigate to learn more about this Club? How?

Answered: 1 week ago