Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why wont the program start

 
Eli Winston
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having trouble with my program when i try to run it it says turn null and won't start. I don't know what is wrong so if you could help me that would be great. I thik the problem is that some how my loops are not being acivated but i have know idea how to trouble shoot this, if you know of a way to trouble shoot this please tell me. (I'm new to Java and i am very new to applets)




This is the assignment:

This project involves writing an applet to simulate a tortoise and hare race. The contenders will each race along a horizontal course that contains a lane for each of them. The course should have at least 50 squares or positions…you may add more if you wish. The race begins with each contender at position 1 of their respective lanes. The contender that first reaches or passes the last square of the course is the winner of the race. The following table indicates the types of moves that each contender can make. Contender Type of Move Percentage of Time Result of Move Tortoise Fast plod 50% 3 squares to right Slow plod 30% 1 square to right Slip 20% 6 squares to left Hare Big hop 20% 9 squares to right Small hop 30% 1 square to right Big slip 10% 12 squares to left Small slip 20% 2 squares to left Fall asleep 20% Each contender starts at position 1. When a contender slips, they can’t slip any further left than position 1. You will use a random number generator to simulate the percentages of each type of move indicated in the table. Generate a random integer, n, in the range 1 ≤ n ≤ 10. For the tortoise, perform a fast plod if the number is 1-5, a slow plod if the number is 6-8, and a slip if the number is 9-10. For the hare, perform a big hop if the number is 1-2, a small hop if the number is 3-5, a big slip if the number is 6, a small slip if the number is 7-8, and fall asleep if the number is 9-10. You must keep track of each contender’s position and display each contender’s position using a graphics image. Graphics images for the tortoise and hare can be found in the course downloads folder. You may have to adjust the length of the course and the size of the applet window to get just the right look. Hint: Get the overall logic for the program working before you deal with the graphics. You might find it helpful (but it is not absolutely necessary) to structure the overall control flow based on a simulation clock. Each time the clock “ticks” the contenders move. Make sure your source code is commented, and submit your code in a zip file.

Here is the code:

 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the exception message and stack trace
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic