Question: 1. Write a new Java program named Project1.java that implements your game. Your game must include: 6 shapes: [Start], [Stop], [+=], running sum, increment, and

1. Write a new Java program named Project1.java that implements your game. Your game must include: 6 shapes: [Start], [Stop], [+=], running sum, increment, and elapsed time. All may be Rectangle objects, or some other shape class. 5 methods: a main() method and four additional methods, one each to handle the mouse-pressed events for [Start], [Stop], [+=], and increment.

2. Your main() method should do the following: Instantiate and style all your shape objects. Set the mouse-pressed handler methods for the four clickable shapes. Initialize other variables, as necessary.

3. Your [Start] mouse-pressed handler method should do the following: Reset the running sum to 0 and update the display. Regenerate a new random increment in the range [1,9], save, and update the display. Read the current time using System.currentTimeMillis(), and save it as the game start time. Clear the elapsed time display.

4. Your [Stop] mouse-pressed event handler method should do the following: Read the current time again using System.currentTimeMillis(), and subtract the start time, recorded earlier. Update the elapsed time display with the difference.

5. Your [+=] shape mouse-pressed event handler method should do the following: Add increment to the running sum. Update the running sum display to the newly incremented value. 6. Your increment shape mouse-pressed event handler method should do the following: Generate a new integer in the range [1,9] and save it. Update the increment shape text with the new increment value.

7. Compile and run your game program. Make sure it operates as expected.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!