Help with Dice Simulation

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2008
Posts: 37
Reputation: IMtheBESTatJAVA has a little shameless behaviour in the past 
Solved Threads: 0
IMtheBESTatJAVA IMtheBESTatJAVA is offline Offline
Light Poster

Re: Help with Dice Simulation

 
0
  #11
Dec 1st, 2008
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".

  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...
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,677
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 226
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: Help with Dice Simulation

 
0
  #12
Dec 1st, 2008
This:
  1. public class Rolling
  2. {
  3. private random myDie;
  4. }
  5. public static void main(String[] args) {
  6.  
  7. }

Should be:

  1. public class Rolling
  2. {
  3. private random myDie;
  4.  
  5. public static void main(String[] args) {
  6.  
  7. }
  8. }
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Help with Dice Simulation

 
0
  #13
Dec 1st, 2008
Originally Posted by IMtheBESTatJAVA View Post
I checked all of my {'s.
Seemingly not.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC