Assignment #3

Due: Friday, October 15, 2PM

In this lab you will create a simple draw program. This lab will give you some practice in writing and using classes as well as using polymorphism. You also will have to explore portions of the Java API and learn to use some of the classes which Java has already created for you. Finally, you will have to be familiar enough with generic classes that you can use a generic class which I will provide although you do not yet have to be able to create your own generic classes.

I have provided you with the user interface in the file Draw.java. When you run the applet as it is, you will have a window with several Graphical User Interface `widgets' which the user can use to instruct the program in what to draw. The first one allows the user to choose between one of several colors. The second allows the user to choose a shape. When you change one of these preferences, you will notice that the change is indicated in the status bar at the bottom of the applet. You can find the corresponding `showStatus' command in the code. This is where you should put your code which initiates the response to the users input.

If you click with the mouse anywhere else on the applet window besides on one of the widgets, then the location of the pixel where the button was released will be indicated in the status bar. The corresponding showStatus command is located in the method mouseClicked . The user can use the mouse in this way to indicate the location and size of the shape to be drawn. For example, if the user has chosen a circle shape, the first click would indicate where the user wants the center of the circle to be placed and the second click would indicate how far out the radius should extend. Once the user has input enough points to specify the shape, that should trigger the program to draw the new shape (in addition to all the previous shapes) on the screen. The exception to this is a polygon which can have an arbitrary number of points. The final point of a polygon is indicated by clicking on the Last Point button. Here are how input points specify each of the shapes: