Develop the \'Shape\' application such that: Rectangle\', \'Ellipse\', and \'Tri
ID: 3571755 • Letter: D
Question
Develop the 'Shape' application such that: Rectangle', 'Ellipse', and 'Triangle' classes inherit from the 'Shape' class. Develop the 'Square' and 'Circle' class where 'Square' inherits from 'Rectangle' and 'Circle' Inherits from 'Ellipse'. 'Triangle' has no derived class. For each class, implement the overridden methods 'draw', 'move', and 'erase'. Each method should only have an output statement such as "Rectangle - draw method" that will be displayed when the method is Invoked. Implement the default constructors for each class with a corresponding message to be displayed when invoked. No initializations are required; that is, the output message will be the only executable statement In the constructors. Do not implement any other methods for these classes (i.e., 'toString', 'equals', getters and setters). Implement a 'ShapeTest' class which will instantiate an object of each class. Exercise each of the 'draw', 'move', and 'erase' methods of each class Remember to make sure that there is only a single class per file. Develop the 'Shape' application such that: Implement an array of objects of various types (all SIX classes), in any order. In some type of a looping structure, demonstrate polymorphism by calling all three of the methods, draw, move, and erase. That is, within the curly braces, there will be only three method calls. Verify that the output messages come from all three methods, from all seven classes. The only class that you should have to develop for this class will be the test application. The six shape classes from Lab-7 should remain unchanged.Explanation / Answer
Please find the required program along with its output. Please see the comments against each line to understand the step.
----------------------------------------------------------------------------------------
OUTPUT:
Constructor : Shape
Constructor : Shape
Constructor : Rectangle
Constructor : Shape
Constructor : Eclipse
Constructor : Shape
Constructor : Triangle
Constructor : Shape
Constructor : Rectangle
Constructor : Square
Constructor : Shape
Constructor : Eclipse
Constructor : Circle
Rectangle - draw method
Rectangle - erase method
Rectangle - move method
Eclipse - draw method
Eclipse - erase method
Eclipse - move method
Triangle - draw method
Triangle - erase method
Triangle - move method
Square - draw method
Square - erase method
Square - move method
Circle - erase method
Circle - draw method
Circle - move method
Calling using polymorphism:
Rectangle - draw method
Rectangle - move method
Rectangle - erase method
Eclipse - draw method
Eclipse - move method
Eclipse - erase method
Triangle - draw method
Triangle - move method
Triangle - erase method
Square - draw method
Square - move method
Square - erase method
Circle - draw method
Circle - move method
Circle - erase method
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.