CIS2168 - Homework 2

Handed out: 09/07/10
Due: by 10pm on 09/13/10

Assignment 2: Jumping Button [plagiarized from Dr. Lakaemper]

This assignment handles topics of events and GUI-elements. It's a little game. The task: create a button that randomly relocates to a different position on the screen each time it is hit. The player has to hit the button 15 times, the score is the time needed.

Your first task: write the necessary event handling and the game-framework (counter, score etc.). Measure the time using java's System.currentTimeMillis() method (see API). Display the time elapsed and the number of remaining hits on separate JLabels.

Your second task: to make the game more mean, surround the button with 8 buttons (GridLayout 3x3) which the player is NOT allowed to hit. if the center button is sufficiently small, the game becomes really hard. If the user clicks one of the 8 bad buttons by accident, the following should happen:
first time and second time: the center button becomes smaller, but the game continues.
third time: game over.

Here's the class JumpingButton, your starting point for the first task. If you create an instance of this class, a button in the center of the screen will appear. Clicking it results in nothing, since no event handling is built in. The class also has a method 'relocate()'. If you call that class, the button will be displayed at a random position on the screen.

Full credit will be given even if you do only the first task. But I hope that many students will do both tasks.