Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Draw {
- public int[] digits = new int[3];
- Random random = new Random();
- public void Pull()
- {
- for (int i = 0; i < digits.length ; i++) {
- digits[i] = random.nextInt(10);
- }
- }
- }
- public class Play {
- public static void main(String[] args) {
- Draw draw = new Draw();
- int counter = 0;
- while (!LuckyStrike.Won(draw)) {
- draw.Pull();
- for (int digit : draw.digits) {
- System.out.print(digit);
- }
- counter++;
- System.out.println();
- }
- System.out.println("After " + counter + " attempts you won!");
- }
- }
- public class LuckyStrike {
- public LuckyStrike(){
- }
- public static boolean Won(Draw draw){
- return draw.digits[0] == 7 && draw.digits[1] == 7 && draw.digits[2] == 7;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement