CSE 341 -- Programming Languages

Winter 2000

Department of Computer Science and Engineering, University of Washington

Steve Tanimoto (instructor) and Jeremy Baer (teaching assistant).

Assignment J1

Version 1.01 of January 26.  Subject to change.

Java Warmup

Due date and time: Monday, January 31, 2000 at 10:30 (Submit your assignment electronically by filling out an online submission form.). 

 

Title: Java -- A Warmup with Objects and Graphics

Purposes:  To learn how to put classes, objects and inheritance  to work; to get started with the Abstract Windowing Toolkit (AWT) and the Java 1.1 event model, and to begin to build some infrastructure that we can use for the in-depth Java assignment as well as the miniproject.

Instructions:  Examine the Sample Java Applet containing a pair of buttons.  Then write a Java applet that includes a class called GeometricObject and two subclasses called Square and Circle.  The applet should contain two buttons. The user will click on "Squares" to start drawing squares and "Circles" to start drawing circles.  After clicking one of these buttons, the user will draw a circle or square by simply clicking within a drawing area on the screen.  Use an instance of the built-in type Canvas to implement the drawing area.  Optional functionality: (1) the ability to control the sizes of the squares and circles, (2) the ability to control the fill color of the squares and circles, (3) using a third button to clear the canvas, (4) adding other geometric shapes, (5) permitting the user to delete a square or circle by clicking on another button ("Delete") and then clicking on the square or circle, (6) allowing the user to put text on the canvas.

Here is an executable for a sample solution.

Programming style:  Comment your function definitions clearly. using the style given in the sample program.