Using C++, Goal You are asked to create a commandline-based interactive program
ID: 3803396 • Letter: U
Question
Using C++,
Goal
You are asked to create a commandline-based interactive program that allows users to add two types of shapes: triangles and circles. The program also allows the user the print the list of stored shapes. Furthermore, it allows the user to modify the stored shapes.
Sample run of this program
The following run illustrates the interactions supported by this program.
-----------------------------------------------------------------------------------------------------------------------------------
Some specifics
If user enters a, the programs prompts the user for information about a triangle (position x, position y, width, and height).
If user enters b, the programs prompts the user for information about a circle (position x, position y, radius).
If user enters p, the program prints the shapes (their types, position x, position y, and other info, e.g., width and height in case of triangles).
The program can store up to 10 shapes.
If user presses 0-9 the shape stored at that index allows user to re-enter the values (e.g., position x, position y, and radious for circle).
----------------------------------------------------------------------------------------------------------------------------------------------------
Source Code
Please complete the Tri and Cir classes in the code below:
MAIN
Explanation / Answer
MAIN
// YOU NEED TO COMPLETE THIS CLASS
class Tri
{
protected:
int _width, _height;
public:
// shapes[n]/location got by calling get_info_from_user();
Shape s = new Shape(location);
Point p = new Point(_width,_height);
// get the shapes and os
s.draw();
s.get_info_from_user(); // get location x and y
for(int i = 0;i < 10;i++)
{
Shapes[n] = s.draw();
return shapes;
}
};
// YOU NEED TO COMPLETE THIS CLASS
class Cir
{
protected:
int _radius;
public:
// shapes[n]/location got by calling get_info_from_user();
Shape s = new Shape(location);
Point p = new Point(_width,_height);
// get the shapes and os
s.draw();
s.get_info_from_user(); // get location x and y
for(int i = 0;i < 10;i++)
{
Shapes[n] = s.draw();
return shapes;
}
};
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.