Define an abstract base class SHAPE that includes protected data members for the (x,y) position of a shape, a public method to move a shape , and a public abstract method show() to output a shape .Derive subclasses for lines, circles and rectangles. Also define the class POLYLINE with SHAPE as the base class. You can represent a line as two points, a circle as a center and a radius. A rectangle as two points on diagonally opposite corners. Implement the toString() method for each class. Test the classes by selecting ten random objects of the derived classes, then invoking the show() method for each class. Use the toString() method in the derived classes.
Comments
Leave a comment