Advertisement
CyrusVerkest

Dice

Nov 17th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. a)
  2. import java.util.Random;
  3. public class Die {
  4.  
  5. private static int sides;
  6. public static int Generator(int sides)
  7. {
  8. sides = 6;
  9. Random dice = new Random();
  10. return 1 + dice.nextInt(sides);
  11. }
  12. }
  13. -----------------------------------------------------------------------------------------------------------------------------------
  14. B)
  15.  
  16. public class DieTester {
  17.  
  18. public static void main(String[] args) {
  19. int n = 0;
  20. final int tries = 10;
  21. for(int i = 1; i <= tries; i++)
  22. {
  23. n = Die.Generator(n);
  24. System.out.println(n + "" ) ;
  25. }
  26. System.out.println();
  27.  
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement