Advertisement
Guest User

Untitled

a guest
Nov 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public class Draw {
  2.  
  3. public int[] digits = new int[3];
  4.  
  5. Random random = new Random();
  6. public void Pull()
  7. {
  8. for (int i = 0; i < digits.length ; i++) {
  9. digits[i] = random.nextInt(10);
  10. }
  11. }
  12. }
  13.  
  14. public class Play {
  15. public static void main(String[] args) {
  16. Draw draw = new Draw();
  17. int counter = 0;
  18.  
  19. while (!LuckyStrike.Won(draw)) {
  20. draw.Pull();
  21.  
  22. for (int digit : draw.digits) {
  23. System.out.print(digit);
  24. }
  25. counter++;
  26. System.out.println();
  27. }
  28.  
  29. System.out.println("After " + counter + " attempts you won!");
  30. }
  31. }
  32.  
  33. public class LuckyStrike {
  34. public LuckyStrike(){
  35.  
  36. }
  37. public static boolean Won(Draw draw){
  38. return draw.digits[0] == 7 && draw.digits[1] == 7 && draw.digits[2] == 7;
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement