diff --git a/src/main/java/baseball/Application.java b/src/main/java/baseball/Application.java index dd95a34214..988882a11b 100644 --- a/src/main/java/baseball/Application.java +++ b/src/main/java/baseball/Application.java @@ -1,7 +1,73 @@ package baseball; +import java.util.Random; +import java.util.Scanner; + public class Application { public static void main(String[] args) { - // TODO: 프로그램 구현 + Scanner scanner = new Scanner(System.in); + Random rand = new Random(); + rand.setSeed(System.currentTimeMillis()); + + int[] computer; + computer = new int[3]; + for(int i=0;i<3;i++){ + computer[i] = rand.nextInt(9)+1; + for(int j=0;j=1){ + System.out.println(ball +"볼"); + } else if( strike != 3 && (strike>=1 && ball ==0)){ + System.out.println(strike + "스트라이크"); + } else if(strike !=0 && strike !=3 &&(strike >=1 || ball>=1) ){ + System.out.println(ball +"볼 " + strike + "스트라이크"); + } else if(strike ==0 && ball==0){ + System.out.println("낫싱"); + }else if(strike == 3){ + System.out.println("3스트라이크"); + System.out.println("3개의 숫자를 모두 맞히셨습니다! 게임 종료"); + System.out.println("게임을 새로 시작하려면 1, 종료하려면 2를 입력하세요."); + int retry = scanner.nextInt(); + if(retry == 1){ + continue; + }else if(retry == 2){ + break; + } + + } + } } }