Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My Programming Lab - C++ Consider a graphics system that has classes for various figures, say rectangles, squares, triangles, circles, and so on. For example,

My Programming Lab - C++

Consider a graphics 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 circle might have only a center point and an edge length or radius, respectively. In a well-designed system, these would be derived from a common class, Figure. It is your job to implement this system. First, implement the base class Figure. Then, implement two classes that are derived from Figure - Rectangle and Triangle. Each class should have stubs for the member functions erase() and draw(). Each of these member functions outputs a message telling what function has been called and what the class of the calling object is. Since these are just stubs, they should do nothing more than output the message. Also implement the member function center(). Typically, center() would call erase and draw to erase and redraw the figure at the center. However, since our functions are only stubs, center() will simply print a message saying that center() has been called from the respective class. It will then call erase() and draw(), which will each print out their own message. You should implement the base class functions as virtual functions. Finally, test your program in main() by creating a Triangle object and a Rectangle object and calling draw(), erase(), and center() on each object.

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

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions

Question

Why do you think these patterns are similar cross-culturally?

Answered: 1 week ago

Question

Does it avoid use of underlining?

Answered: 1 week ago