Using C Consider a graphic system that has classes for vario

Using C++:

Consider a graphic system that has classes for various figures, say rectangles, squares, triangles, circles and so on. For example, a rectangle might have data members height, width and center point. While a square and a circle might have only a center point and an edge length and a radius, respectively. In a well-designed system these would be derived from a common class, Figure. You are to implement such a system. The class Figure is the base class. You should add only Rectangle and Circle classes derived

from Figure. Each class has stubs for member functions erase() and draw(). Each of these member functions outputs a message telling what function has been called and what class of the calling objects it. Since these are just stubs, they do nothing more than output this message. The member function center() calls erase() and draw() to erase and redraw the figure at the center. Because you have only stubs for erase() and draw(), center() will not do any “centering”

but will call the member function erase() and draw(). Also, add an output message in the member function center() that announces that center is being called. Make the base class member functions virtual. Write your own driv

er program to test the center() and draw() for rectangle and circle class objects.

For this simple C++ project, we can divide our codes into several files:

·Assignment.cpp: the application file.

·figure.h: Interface of class figure.

·figure.cpp: Implementation of class figure.

·rectangle.h: Interface of class figure.

·rectangle.cpp: Implementation of class figure.

·circle.h: Interface of class figure.

·circle.cpp: Implementation of class figure.

You can attach all these files above individually then submit or you can package all the files into one archive.

Solution

#include

#include \"figure\"

#include\"rectangle.h\"

#include \"triangle.h\"

useing std::count;

int main( )

{

triangle tri;

tri.draw( );

count<<

\"\ derived class triangle object calling center ( ).\ \";

tri.center c ;

rectangle rect;

rect.draw ( );

count<<

\"\   derived class rectangleobject calling center 0.\ \";

rect.center ( );

reurn 0;

}

Using C++: Consider a graphic system that has classes for various figures, say rectangles, squares, triangles, circles and so on. For example, a rectangle might
Using C++: Consider a graphic system that has classes for various figures, say rectangles, squares, triangles, circles and so on. For example, a rectangle might

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site