Question: Write a Java program that uses the Up, , Down , Right (and possibly Left) arrows of the keyboard (or keypad) to move a

Write a Java program that uses the Up, , Down , Right  (and possibly Left) arrows of the keyboard (or keypad) to move a ball. (note the Up arrow is called "Up" with ASCII code 38, Down arrow is called "Down" with ASCII code 40, Right arrow is called "Right" with ASCII code. You can also use the 4 keys ijkl, commonly used in ODS game programming.


(b) Using Java class JFrame to draw a grid of 5 horizontal lines, 5 vertical lines, a blue pond in the middle occupying 5 squares with a text Pond in the middle, a ball at the lower left corner, and texts called Start and End. This is shown exactly as in Figure 1 here. Change the text in the title bar from "Dr. Lin's key control ball movement" to your own text or change the color of ball from green to another color.



(c) Modify the code of KeyDemo.java and KeyDemoFrame.java of Deitel 9-th edition so that up,down, and right arrows are used to move the green ball at the lower left corner to the lower right corner. In other words, up arrow will move the ball up one square, right arrow moves that one square to the right etc. Turn in the modified code for the instructor to run and verify.



(d) Capture the screens at several different spots when you move the ball and put in the final document(Word or PDF etc.)

Step by Step Solution

3.45 Rating (148 Votes )

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 Programming Questions!