The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 3 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
In C++ write a code to Consider a graphics system that has classes for various figures rectangles, squares, triangles, circles, and so on. For example, a rectangle might have data members for Height, Width and center point, while a square and circle might have only a center point and an edge length or radius. 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 Triangle classes derived from Figure. Each class has two member functions erase and draw Each of the member functions erase and draw outputs a message telling what function has been called and what the class of the calling object is. For example if you call the function erase from the object of type Rectangle, the output is "this is the function Rectangle::erase()". (These functions do nothing more than output this message.) The base class has another extra function named center. The member function center will also output a message like this: "the member function center is called to erase and draw". Then it will calls the erase and draw functions to erase and draw the figure. So basically this function just write a line in the output and then it will call erase and draw functions. All the member functions should take no arguments. There are three parts to this project: Write the class definitions using no virtual functions. Compile and test. Make the base class member functions virtual. Compile and test . Explain the difference in results . Use the following main function for all testing (Remember to include necessary files before main): int main() { Triangle tri; tri.draw(); cout << "\n In main, Derived class Triangle object calling" << " center().\n"; tri.center(); Rectangle rect; rect.draw(); cout << "\n In main, Derived class Rectangle object calling" << " center().\n"; rect.center(); return 0; }
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on-----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be-----------