/The-Great-Race

(Simulation: The Tortoise and the Hare) In this problem, you’ll recreate the classic race of the tortoise and the hare. You’ll use randomnumber generation to develop a simulation of this memorable event. Our contenders begin the race at square 1 of 70 squares. Each square represents a possible position along the race course. The finish line is at square 70. The first contender to reach or pass square 70 is rewarded with a pail of fresh carrots and lettuce. The course weaves its way up the side of a slippery mountain, so occasionally the contenders lose ground. A clock ticks once per second. With each tick of the clock, your application should adjust the position of the animals according to the rules in Fig. 7.32. Use variables to keep track of the positions of the animals (i.e., position numbers are 1–70). Start each animal at position 1 ሺthe "starting gate"ሻ. If an animal slips left before square 1, move it back to square 1.

Primary LanguageJava

The-Great-Race

(Simulation: The Tortoise and the Hare) In this problem, you’ll recreate the classic race of the tortoise and the hare. You’ll use randomnumber generation to develop a simulation of this memorable event. Our contenders begin the race at square 1 of 70 squares. Each square represents a possible position along the race course. The finish line is at square 70. The first contender to reach or pass square 70 is rewarded with a pail of fresh carrots and lettuce. The course weaves its way up the side of a slippery mountain, so occasionally the contenders lose ground. A clock ticks once per second. With each tick of the clock, your application should adjust the position of the animals according to the rules in Fig. 7.32. Use variables to keep track of the positions of the animals (i.e., position numbers are 1–70). Start each animal at position 1 ሺthe "starting gate"ሻ. If an animal slips left before square 1, move it back to square 1.