CS 120A Fall
2001, Instructor: Jeffrey
Horn
HOMEWORK 3: "Handling Java Events: Mice and Keyboards"
- Assigned: Monday, Sept. 17, 2001
- Due: Wednesday, Sept. 26, 2001
- Purpose: Learn
- the Java event model
- EventApplet
- repaint
- arrays
Assignment:
1.Get the EventApplet folder from here.
2.Modify the source code file (".java" file)
to add the following capabilities:
- Write your own class like Tree, that paints a nice re-locatable graphic and is "parameterized" in the following ways:
- x,y coordinates (i.e., re-locatable)
- size
- Color
- anything else you might like (e.g., shape)
- Create an array of objects of your class, and use this to store the varying number of objects of your class that your user will create and delete during runtime. Keep track of the number of objects currently in the array (always filling in the array "from the right", in other words, from positions 0, 1, 2, 3, ...) and make sure the user can't add any more objects after the maximum (the size of the array) is reached!
- Have the following user interactions:
- the ability to add and place new objects (can be done at the same time),
- the ability to delete objects in the reverse order they were added, (make sure your user can't delete objects when there are none left!)
- the ability to reset the entire "game" (i.e., delete all objects)
- In addition to updating the objects, also print the latest mouse click coordinates (x,y) to the system console window, and somewhere on the applet window print the current number of objects.
3. Put your name, date, the class, and the assignment number in comments at the TOP of your source code.
4. Comment EVERY single new variable AND method that you create. For this assignment, i will not be picky about how well you describe each of your variables and methods, I simply want you to have SOME description there!5. Turn in via WebCT.