943,714 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2976
  • Java RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Dec 1st, 2008
0

Re: Help with Dice Simulation

Hmmm... well, I'm getting an error on my code on the line
public static void main(String[] args)
and I checked all of my {'s. The error says "class, interface, or enum expected".

Java Syntax (Toggle Plain Text)
  1. public class Rolling
  2. {
  3. private random myDie;
  4. }
  5. public static void main(String[] args)
  6. {
  7. double seed = Math.random ( ) * 10;
  8. int seedInt = (int)seed;
  9. myDie = new Random (seedInt);
  10. int counter = 0;
  11. int dieRollOne;
  12. int dieRollTwo;
  13. int dieRollThree;
  14.  
  15. do
  16. {
  17. dieRollOne = myDie.nextInt(6) + 1;
  18. dieRollTwo = myDie.nextInt(6) + 1;
  19. dieRollThree = myDie.nextInt(6) + 1;
  20. counter += 1;
  21. System.out.println(dieRollOne + " " + dieRollTwo + " " + dieRollThree);
  22. }
  23. while ((dieRollOne == dieRollTwo) || (dieRollOne == dieRollThree)
  24. || (dieRollTwo == dieRollThree));
  25.  
  26. if(!(dieRollOne == dieRollTwo) && !(dieRollOne == dieRollThree)
  27. && !(dieRollTwo == dieRollThree));
  28. {
  29. System.out.println("Count = " + counter);
  30. }
  31. }

Any help appreciated...
Reputation Points: -1
Solved Threads: 0
Light Poster
IMtheBESTatJAVA is offline Offline
36 posts
since Oct 2008
Dec 1st, 2008
0

Re: Help with Dice Simulation

This:
Java Syntax (Toggle Plain Text)
  1. public class Rolling
  2. {
  3. private random myDie;
  4. }
  5. public static void main(String[] args) {
  6.  
  7. }

Should be:

Java Syntax (Toggle Plain Text)
  1. public class Rolling
  2. {
  3. private random myDie;
  4.  
  5. public static void main(String[] args) {
  6.  
  7. }
  8. }
Sponsor
Featured Poster
Reputation Points: 1014
Solved Threads: 446
Nearly a Senior Poster
javaAddict is offline Offline
3,258 posts
since Dec 2007
Dec 1st, 2008
0

Re: Help with Dice Simulation

I checked all of my {'s.
Seemingly not.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Solve My Question Pls....
Next Thread in Java Forum Timeline: Need help with adt table





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC