Lab #2
Design an abstract Shape class that has abstract methods draw and resize. The class has also a getShapeName method and a toSting method that returns the name of the shape drawn and prints it on the screen. Implement the following shapes:
  • Point with draw method and toString method that returns the name of the shape
  • Line with draw and resize methods and toString method that returns the name of the shape
  • Circle with draw and resize and toString method that returns the name of the shape
  • Triangle withdraw and resize methods and toString method that returns the name of the shape
  • The resize method allows user to put new dimensions for the same shame that has already been drawn.


Design a test program for the Shapes. The program is an application. The shapes are drawn on command window (unless you know how to create a panel). The test program provides the names of the shapes and the sizes to be drawn as follows:
  • Coordinates to draw the point.
  • Coordinates to draw the line
  • The radius of the circle
  • The coordinates of three points that define the triangle.

Since we are doing graphics in this lab a container is needed. The container can be any of your choice, Applet, Frame, or a Panel (within the applet or the frame)

There is a sample program available.