Rewrite Exercise using a thread to control car racing. Compare the program with Exercise by setting the
Question:
Rewrite Exercise using a thread to control car racing. Compare the program with Exercise by setting the delay time to 10 in both programs. Which one runs the animation faster?
Write a program that simulates car racing, as shown in Figure. The car moves from left to right. When it hits the right end, it restarts from the left and continues the same process. You can use a timer to control animation. Redraw the car with a new base coordinates (x,?y), as shown in Figure. Also let the user pause/resume the animation with a button press/release and increase/decrease the car speed by pressing the UP and DOWN arrow keys.
(a) The program displays a moving car.
(b) You can redraw a car with a new base point.
Step by Step Answer:
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang