diff --git a/baseball_game/src/main/java/Game/Answer.java b/baseball_game/src/main/java/Game/Answer.java index d74fc2b..091a3d8 100644 --- a/baseball_game/src/main/java/Game/Answer.java +++ b/baseball_game/src/main/java/Game/Answer.java @@ -33,12 +33,9 @@ public Boolean checkAnswer(int guess) { int tens = (answerNumber/10)%10; int hundreds = answerNumber/100; - // strike 수 세기 - Evaluate.countStrike(guess, hundreds, tens, units); - Evaluate.countBall(guess, hundreds, tens, units); - - int strike = Evaluate.getStrike(); - int ball = Evaluate.getBall(); + // strike, ball 수 세기 + int strike = Evaluate.countStrike(guess, hundreds, tens, units); + int ball = Evaluate.countBall(guess, hundreds, tens, units); if(strike==0 && ball==0) { System.out.print("낫싱\n"); diff --git a/baseball_game/src/main/java/Game/Evaluate.java b/baseball_game/src/main/java/Game/Evaluate.java index c364cf7..50d5558 100644 --- a/baseball_game/src/main/java/Game/Evaluate.java +++ b/baseball_game/src/main/java/Game/Evaluate.java @@ -1,35 +1,22 @@ package Game; public class Evaluate { - private int inputNumber; - private static int strike; - private static int ball; + public Evaluate(int guess, int answer) {} - public Evaluate(int guess, int answer) { - - } - - public static int getStrike() { - return strike; - } - public static int getBall() { - return ball; - } - - public static void countStrike(int guess, int hundreds, int tens, int units) { + public static int countStrike(int guess, int hundreds, int tens, int units) { int strikeN = 0; if(guess%10 == units) strikeN++; if((guess/10)%10 == tens) strikeN++; if(guess/100 == hundreds) strikeN++; - strike = strikeN; + return strikeN; } - public static void countBall(int guess, int hundreds, int tens, int units) { + public static int countBall(int guess, int hundreds, int tens, int units) { int ballN = 0; if((guess%10==hundreds) || (guess%10==tens)) ballN++; if(((guess/10)%10==hundreds) || ((guess/10)%10==units)) ballN++; if((guess/100==tens) || (guess/100==units)) ballN++; - ball = ballN; + return ballN; } }