Link to home
Start Free TrialLog in
Avatar of ahdeenhu
ahdeenhu

asked on

Creat a Shapes class program to display different shape of figure from a derived class.

The program is asking to create a Shapes class program  that dynamically displays either a triangle, rectangle or a circle from a derived class, depending on a user's selection.  the three figures are giving as follows:
rectangle::
cout<<"*******"<<endl;
cout<<"*******"<<endl;
cout<<"*******"<<endl;
cout<<"*******"<<endl;

triangle::
cout<<"*"<<endl;
cout<<"**"<<endl;
cout<<"***"<<endl;
cout<<"****"<<endl;

circle::
                cout<<"     * * *"<<endl;
      cout<<"    * * * *"<<endl;
      cout<<"   * * * * * "<<endl;
      cout<<" * * * * * * *"<<endl;
      cout<<"  * * * * * *"<<endl;
      cout<<"   * * * * *"<<endl;
      cout<<"    * * * *"<<endl;
the problem asks to add a virtual function named drawShape() in the Shapes class, and we have to override the drawShape() function and include the figures above to the derived class, in the program's main() function, instantiate a Shapes class pointer, then create a looping statement that display a menu allowing users to pick the type of shape they want.  when the user picks a shape, instantiate a new object of that shape's class and assign it to the Shapes class pointer.  and we need to use the Shapes class pointer to call the getShapeType() and drawShape() function, and last modify the Shapes class to be an abstract base class.

i'm quiet confusing about where to put those figures above, how to instantiate the Shapes class pointers, and how to use the Shapes class pointers to call the getShapeType() and drawType() function. do we need to have setShapeType() function? and we suppose to have three derived classes and one base class. and do we need to declare any data type for the figures?

thank you very much!
ahdeenhu
ASKER CERTIFIED SOLUTION
Avatar of Svetlin_Panayotov
Svetlin_Panayotov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial