Question: In Java Programming language; RaceGame is a text based car racing game. The user is car #1 and the computer is car #2. A car

In Java Programming language;

RaceGame is a text based car racing game.

The user is car #1 and the computer is car #2.

A car is drawn using 2 lines. The number on the first line is 1 for the user and 2 for the computer.

__/1\__

-O---O-

When the car has moved down the track, print underscores on the second line showing how many spots. For example, if the car has moved 3 spots total, it would look like:

__/1\__

_____-O---O-

The track is 20 spots long.

The track is drawn as 27 ~s. 20 spots that the cars have to move plus 7 move because that is how wide the car is when it is drawn

The track looks like:

~~~~~~~~~~~~~~~~~~~~~~~~~~~

When either car reaches the 20th spot, the game is over

How to play the game:

Ask the user if he/she wants a regular roll or to go for double or nothing.

For a regular roll, move the car that many spaces forward

For a double or nothing roll: if you roll an odd number, move twice that many spaces; if you roll an even number, then move no spaces

Then roll the die for the computer. Move the computers car that many spaces

After both cars move, draw both cars on their track

Print the track

When one of the cars has moved at least 20 spaces, the game is over. Print a message to say who has won

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!