Answered step by step
Verified Expert Solution
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;
virtual void DisplayArea;
;
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 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 objectsinstances 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;
RDisplayRectangle;
RDisplayArea;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started