Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement a graphics System that has classes for various figures: rectangles, sq

ID: 3557277 • Letter: I

Question

Implement a graphics System that has classes for various figures: rectangles, squares, triangles and circles. A rectangle has data members height, width, color , and center point. A square has center point and an edge and color . A circle has data members center, color and radius. The several specific shape classes are derived from a common class, Figure.

Implement classes Rectangle, Square, Triangle and Circle classes and derive them from class Figure.

In addition to constructor, destructor and set/get functions, each class has two virtual functions erase and draw to draw or erase the shape.

To draw or erase a figure you must use OpenGL graphics library.

TO RECEIVE FULL CREDIT PLEASE SHOW SCREENSHOTS.

Explanation / Answer

and

A trial run follows:

-------------------------------

With Virtual erase and draw

-------------------------------

Triangle::draw()

In main, Derived class Triangle object calling center().

member function center called

Triangle::erase()

Triangle::draw()

Rectangle::draw()

In main, Derived class Rectangle object calling center().

member function center called

Rectangle::erase()

Rectangle::draw()

-------------------------------

Without Virtual erase and draw

-------------------------------

Triangle::draw()

In main, Derived class Triangle object calling center().

member function center called

Figure::erase()

Figure::draw()

Rectangle::draw()

In main, Derived class Rectangle object calling center().

member function center called

Figure::erase()

Figure::draw()

-------------------------------

Explanation of difference

-------------------------------

The differences are due solely to the presence or absence

of the keyword virtual in the base class figure.

2. Flesh out Problem 1. Give new definitions and member functions for Figure::center, Figure::draw, Figure::erase, Triangle::draw, Triangle::erase, Rectangle::draw, Rectangle::erase, so that the draw functions actually draw figures on the screen using asterisks (*). For the erase function, clear the screen.

No solution to this part is provided.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote