Java 2일차 베이스볼 게임 알고리즘 테스트

import java.util.Scanner;

public class BaseballTest {
public static void main(String[] args) {

int baseball[] = new int[3];
int random, tmp;
boolean check = true;

for(int i=0; i<baseball.length; i++)
{
random = (int)(Math.random()*9+1);

for(int j=0; j<baseball.length; j++)
if(baseball[j] == random)
check = false;

if(check)
{
baseball[i] = random;
System.out.print(baseball[i]+" ");
}
else
i--;
}
System.out.println();

Scanner sc = new Scanner(System.in);

int num1, num2, num3;
int strike = 0;
int ball = 0;

while(true)
{
System.out.println("첫번째 숫자 입력");
num1 = sc.nextInt();
System.out.println("두번째 숫자 입력");
num2 = sc.nextInt();
System.out.println("세번째 숫자 입력");
num3 = sc.nextInt();

if(num1 == baseball[0]) strike++;
if(num2 == baseball[1]) strike++;
if(num3 == baseball[2]) strike++;
if(num1 == baseball[1] || num1 == baseball[2]) ball++;
if(num2 == baseball[0] || num2 == baseball[2]) ball++;
if(num3 == baseball[0] || num3 == baseball[1]) ball++;

System.out.println(strike+" strike, "+ball+" ball.");

if(strike==3)
{
System.out.println("성공");
break;
}

strike=ball=0;
}

}
}