Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//follow the code bellowwww ( main code ) only change the main code according to the output. Thanks... OUTPUT SHOULD BE ABLE TO SHOW ---

//follow the code bellowwww ( main code ) only change the main code according to the output. Thanks... OUTPUT SHOULD BE ABLE TO SHOW --- *THE LIST OF SHAPE , SELECT SHAPE , RESIZE SELECTED SHAPE AND MOVE SELECTED SHAPE.*

FOLLOW OUTPUT

#include #include #include #include

#include "shape.hpp" #include "circle.hpp" #include "rect.hpp"

using namespace std;

// ? Notes: Choose the debug mode "Multi-File Graphic Project" to run this program.

// You may change the max size of the list #define COUNT 5

int main() { int width = getmaxwidth(); int height = getmaxheight(); initwindow(width, height, "Exercise 5");

/* initialize random seed: */ srand(time(NULL));

char ch = 0;

while (ch != 27) // 27 is ESC key { if (kbhit()) { ch = getch(); switch (toupper(ch)) { case '+': break;

case '-': break;

case KEY_LEFT: break;

case KEY_RIGHT: break;

case KEY_UP: break;

case KEY_DOWN: break; } }

if (ismouseclick(WM_LBUTTONDOWN)) { } } return 0; }

*THE LIST OF SHAPE , SELECT SHAPE , RESIZE SELECTED SHAPE AND MOVE SELECTED SHAPE.*

//////Others multiple file ( no need to edit those )

//circle.cpp #include #include

#include "circle.hpp"

Circle::Circle(int _x, int _y, int _radius): radius(_radius) {}

//circle.hpp

#ifndef CIRCLE_H #define CIRCLE_H

class Circle { protected: int radius;

public: Circle(int _x = 0, int _y = 0, int _radius = 0); };

//rect.cpp #include

#include "shape.hpp" #include "rect.hpp"

Rect::Rect(int _x, int _y, int _width, int _height) : width(_width), height(_height) {}

//rect.hpp #ifndef RECT_H #define RECT_H

class Rect { protected: int width, height;

public: Rect(int _x = 0, int _y = 0, int _width = 0, int _height=0); };

#endif

//shape.cpp #include #include "shape.hpp"

Shape::Shape(int _x, int _y) : x(_x), y(_y), selected(false) {}

void Shape::setLocation(int _x, int _y) { x = _x; y = _y; }

void Shape::setSelected(bool _selected) {selected = _selected;}

//shape.hpp #ifndef SHAPE_H #define SHAPE_H

class Shape { protected: int x, y; // for location bool selected; // to indicate whether the shape is selected or not public: Shape(int _x = 0, int _y = 0); void setLocation(int _x, int _y); void setSelected(bool _selected); };

#endif #endif //////////END OF MULTIPLE FILE.

*THE LIST OF SHAPE , SELECT SHAPE , RESIZE SELECTED SHAPE AND MOVE SELECTED SHAPE.* please solve it by the code c++. please no misuse.

image text in transcribedimage text in transcribed

Question In this exercise you will be writing a C++ program that implements the concept of polymorphism. The program will do some manipulations on two types of shapes, circles, and rectangles, including resizing and moving the shape. The program will show a list of shapes on the screen randomly. However, the user can only manipulate one shape at a time. In this case, he or she first needs to choose a shape from the list using a mouse click. Table 1 shows the list the operations and their commands. Expected result of the program is given in several videos that come with this exercise. Table 1: The commands for the user User Interaction Mouse click Operation To choose a shape that the user will be manipulating or working on. To enlarge or shrink the selected shape. To move the object accordingly, i.e, to the left, right, up or down. Keyboard press + or - Arrow keys You are expected to write the program by separating class specification and implementation into their dedicated files, i.e. hpp and .cpp respectively. In fact, the separation has been done for you in the codebase that comes with this exercise. Besides, the code for some parts of the program has been provided including the basic structure of each class, and the main loop in the main function. Modify the codebase to achieve the goal of the program. Note that you must implement the concept of polymorphism to write the program. Formulas Below are the formulas that you may need to use in your code: Determining whether a mouse click is inside a circle. Assuming a mouse click at location (mx,my), the mouse is considered inside the circle if its distance from the circles center (cx,cy), d is smaller than or equal to the circles radius, r. i.e, d

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

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions