Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- class Figure {
- protected:
- float x, y, vx, vy, angle, scale;
- public:
- Figure() {
- x = 0;
- y = 0;
- vx = 0;
- vy = 0;
- angle = 0;
- scale = 0;
- }
- virtual void create_figure() = 0;
- virtual void show() = 0;
- virtual void delete_figure() = 0;
- virtual void turn() = 0;
- virtual void move() = 0;
- };
- class Circle: public Figure {
- public:
- Circle() {};
- ~Circle(){};
- void create_figure();
- void show();
- void delete_figure();
- void turn();
- void move();
- };
- void Circle::show() {
- cout << "Coordinates of center:" << endl;
- cout << "\tx = " << x;
- cout << "\ty = " << y << endl;
- cout << "Scale of the circle: " << scale << endl;
- }
- void Circle::create_figure(){
- cout << "Set coordinates of center of the circle:" << endl;
- cout << "x = ";
- cin >> x;
- cout << "y = ";
- cin >> y;
- cout << "Set scale of circle: ";
- cin >> scale;
- cout << endl;
- }
- void Circle::delete_figure(){
- cout << "Circle was deleted." << endl;
- x = 0;
- y = 0;
- scale = 0;
- angle = 0;
- }
- void Circle::turn(){
- cout << "Set the angel of rotations of the circle: ";
- cin >> angle;
- cout << "Circle was rotated at " << angle << " degrees\n";
- }
- void Circle::move(){
- cout << "Set coordinates of vector to move the circle:" << endl;
- cout << "x = ";
- cin >> vx;
- cout << "y = ";
- cin >> vy;
- x += vx;
- y += vy;
- cout << "New coordinates of center of the circle: x = " << x << "; y = " << y << endl;
- }
- int main() {
- Figure *f;
- Circle obj1;
- f = &obj1;
- f->create_figure();
- f->show();
- f->turn();
- f->move();
- f->delete_figure();
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement