Java Homework Help Needed
So I received this assignment from my Instructor and I am having a hard time wrapping my mind around it and getting it to work.
Not sure how much of you guys are willing to help, but I hope that some one can successfully code it so I could look at it and study it and see how it was done.
We are using Eclipse to code.
Code:
The Ford vs. Chevy car race
Our two cars begin the race at the starting gate “square 1” of 70 squares. Each square represents a
possible position along the race course. The finish line is at square 70. The first car to reach or pass
square 70 is the winner. There is a clock that ticks once per second and with each tick the computer
should adjust the position of the cars.
After each tick of the clock, display each car’s position on the course. The amount to move a car should
be determined by generating a random number between 1 and 10 and applying it as follows;
FOR FORD
If the number is between 1 and 5 move forward 3 spots.
If the number is between 6 and 8 move back 2 spots
If the number is 9 do nothing
If the number is 10 move forward 5 spots
FOR CHEVY
If the number is 1 move forward 5 spots
If the number is 2 do nothing
If the number is between 3 and 5 move back 2 spots
If the number is between 6 and 10 move forward 3 spots
For each tick of the clock (i.e. each repetition of the loop), print a 70 position line and show the position
of the Ford and Chevy cars by placing a F and C at their respective positions. Occasionally both cars will
be on the same space and when this happens you should print “2 car pileup”.
After printing each line, check to see if either car has reached or passed space 70. If this has happened,
terminate the program and print which car won.
Be sure to document your code with comments.
Again, if some one could do the coding for this successful, that would be great!
Thanks!