From 9de23048c5276caeb9c97ad6b0ad896941a24a1f Mon Sep 17 00:00:00 2001 From: junwoong2 <117076854+junwoong2@users.noreply.github.com> Date: Mon, 6 Nov 2023 21:44:00 +0900 Subject: [PATCH 01/13] . --- src/main/java/baseball/Application.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/baseball/Application.java b/src/main/java/baseball/Application.java index dd95a34214..46fdd2d6b9 100644 --- a/src/main/java/baseball/Application.java +++ b/src/main/java/baseball/Application.java @@ -1,7 +1,15 @@ package baseball; +import java.util.ArrayList; + public class Application { public static void main(String[] args) { // TODO: 프로그램 구현 + Random computer = new Random(); + ArrayList random = new ArrayList<>(); + random = computer.Computer(); + + System.out.println(random); } + } From 9971fb7410776c7b0f66cab6b853541bb2e7a03d Mon Sep 17 00:00:00 2001 From: junwoong2 <117076854+junwoong2@users.noreply.github.com> Date: Mon, 6 Nov 2023 21:46:24 +0900 Subject: [PATCH 02/13] . --- bin/baseball/Application.class | Bin 0 -> 394 bytes bin/baseball/ApplicationTest.class | Bin 0 -> 1889 bytes bin/main/baseball/Application.class | Bin 0 -> 843 bytes bin/main/baseball/Check.class | Bin 0 -> 462 bytes bin/main/baseball/Random.class | Bin 0 -> 929 bytes bin/test/baseball/ApplicationTest.class | Bin 0 -> 3200 bytes src/main/java/baseball/Check.java | 18 ++++++++++++++++++ src/main/java/baseball/Random.java | 18 ++++++++++++++++++ 8 files changed, 36 insertions(+) create mode 100644 bin/baseball/Application.class create mode 100644 bin/baseball/ApplicationTest.class create mode 100644 bin/main/baseball/Application.class create mode 100644 bin/main/baseball/Check.class create mode 100644 bin/main/baseball/Random.class create mode 100644 bin/test/baseball/ApplicationTest.class create mode 100644 src/main/java/baseball/Check.java create mode 100644 src/main/java/baseball/Random.java diff --git a/bin/baseball/Application.class b/bin/baseball/Application.class new file mode 100644 index 0000000000000000000000000000000000000000..b6ead2c6d325c5823703d2cce4c5b549a46c1ab1 GIT binary patch literal 394 zcmZus!A`B`0k3H=4XaBA3=>3zOXg(F0l z+G=-2XpK+jgz%<%QVCkF#gT&-<6Y4&nmihj6*CM2_JQy1!1`}O^;qb~d`oIu>m{Xif;aV;22 zmP#av?Xx%Ry*6|r=xK;xU$FbrAn`!54i3?iiWi^D^L_MR7;Oo~4UU?|fnb2)H@>7z ArvLx| literal 0 HcmV?d00001 diff --git a/bin/baseball/ApplicationTest.class b/bin/baseball/ApplicationTest.class new file mode 100644 index 0000000000000000000000000000000000000000..04b7e37c7ebc67a7a8b9cb7a5e9c3e8e78b7de75 GIT binary patch literal 1889 zcmd5-O-~a+7=EV|T51)nAc$Y%$Dt%jFP=n6h|x$=Fo8mxU#Enfsl0a{rHCVxAvRb%Pu5-r{=(;APuww)|^24(Pk~dU^ zr=Xia&o=g^)=H=05J|kaD>XODZSV?pl;;b#>45rLm0j+ct2EPHs&OhjUujDn=J_~C zsVpsXy7lP}jMCMSdVnz;1Z;<_9Zckq8N;=$ALQ~N=#+^{8^c1aqKw)FpJT3VK(J&U zw>4Fvt;nXCtSE0P@XB0INVKXvqRHon>E$tcfAJC(((XG9Q(9J6|2hNhTyFrsiWKq+Wm}Rt>JTsBnt8G@W}~S}d^%eB8(= zu~z*u8A!w7EOf#V0{!{owuon}7P2}TiM*$Xb!ip1#89^caz*7Zca~`p*_$tuwk8aL zq2hi$HHwR0->!yhOX17qZ?9J8Hl8ibg==rZhtI>cM+8nz2hs|UPsoNa0*S|?PH1)v z@^%%YEgen60D;f#^woc@BRpKfClA7>>vJ2+tKrJ)jg|E@3=w$zk23p12@*(cDlZME z2`v6R%B^Ev6Vg%A2xC$Dw*}WsJGF%roJT3O z4k7~CNns4iyo4QLfC3)t_;UbA;@t^dXs7V$3ce*cXFfpsUM}+vvY*gOKo5=)25`L> z$7~A)MhRxP?N;GM)Q&;0Z4}CA=<0SG>hU=gz zP??2Hj3%QrmD7$M8xIw@_RFS^8@MS@I!vO`#HdtYv(e15EQhpRY~i+p?Ij_))3H&J zk2|m}Y8|DV31v zkV;in2tg8qIf;!+DKkB&Vlka5Gq3PJepdgb-b_aq{b{WdWPhQ;*RfGUm9`I<#_J}N zbf8{o+wSth5bfDUPzDOcc>{91aZ0#5d<8rO&$ZSmO5bK~kGpl#h%4Ov^Sh6$e7U%W zby{rjSAtp4?K6}=o^r^}P~llS`ic6{cih_jfgOvPhsCTD4=8cD903niB5x7X=Ge(_ i@EA{Kf2wGp$t-35Y2hjJ?9y&4$t=%iH1=rAA@~Q3FTp|p literal 0 HcmV?d00001 diff --git a/bin/main/baseball/Check.class b/bin/main/baseball/Check.class new file mode 100644 index 0000000000000000000000000000000000000000..8a70331dcb69a70f8b724dd0fbf666525d6c3f2d GIT binary patch literal 462 zcmY*VJx>Bb5Pf@mpD2i;mM0Yu3j^A~Fp5Yne!M z%aCcd1`OG*8VVN~l*-5<&rk_uA|95rQ0PY<#)6?1sEEe{uBENFVAhP~f((NHt{sM4 zw6U*}*3SM;Yo&{*G4!4iEfy+XiJ=#%*<8llNR@bVtw?@$<+-K)Yhw6|C+v(zlu=WW zc#T%$!W)WM7~xs>4eYw8;Mjh?&QNa#JIlV&G8uL3mTq4ybtLYk-N#Mub7>oK4mt!K z5pd{52cTG>%BRdI=h|x&-%{G8XlVkmN3pzpm$6S(2?u|}?X9Hyfy#63aE+rc>Ts}A OsHO@Ip$sP}clrx?z+sF4 literal 0 HcmV?d00001 diff --git a/bin/main/baseball/Random.class b/bin/main/baseball/Random.class new file mode 100644 index 0000000000000000000000000000000000000000..23482a46b2f18f620fa9a2a9903f43784324f744 GIT binary patch literal 929 zcmZ`%+iuf95IvilB(r5A#FBx7&2RaUlfprZXk;s<>^RIJdTGw5j^ER zS1^=2zQf%e9!P~JhneV=3>oG+|CMbqH za^UeO4yeG|^r&`nb8YK4V=Rgy<;Suz2w!lM*jC(w|o2g$k}4xTb>Byx&*2VW5fY z)U8myA!gJ%TR8)gxN?fXxnMj742(jnCtG+h`qRedwA<5#XPD_m+}V4?N0S*Sbp1GR z!~?0Oq?nA|x)KSiAbK>MK#DAyD_S)|7VV7oZ1V{DPh)q1R^U;_g}HH(cVwjqZ+t=d`4JW#en2f#(vMMTHV(&+mf}&R8hMyl!wo`ZERaXh-yozoCcc}5ZqctJ^#er> N|%jGz~wKo)4$;I++^saotDSyn%;ZQJ=u4kbN0E(-~ZkI3&1X1 z6;Q>ndPsG&A=NOH-a^69v#P6G=78q70-_8pSv6l!Ol`t-T&zS2rBR zB}e6u!~GdzJ9SfcpJj+NH6Le)_F2PP91&DYSb`WsZAv$_LtcJJvj@~6Lt~IrR#r8R ztG3S9C1cbb)g6ZV)MCt%wE6FElf~;7ia%YP{&{k6=7$S|#p^eUSAHyB|AJx7QO|Vs zymnl7bb{?QP0RJeBGh#$%g!ld9ucMg1>MzbMJ?zGk02>iUStU?P{$x>6I#}DiRAvK z#hElO0ypBBS)NE`uaCl`OUAJZs|7s9uzXA%R~17wb4tJIYB|l8um<&X=(uWl+Tjs~ zRZacPsR}p3SceS))-$v|Ol5izK`b}Epw4j8?njRsb z1^As@z{a(ZC|#6lo$naAH z+cOWUx+$QU0L$4+yS8rT;&=*A3)sp~w~(?Vv_c`(<_Uo3KO9N`kmP5GhMFH5RvWi5 z#P?2QwSu2s0UZo0$|nwt+SVCfbrGG^5AEB#M0C@nt)o-K4hGgHf@B=&+|ey!7oYU( z5V4y!+T)a&UI}|RnFs~M*UwAXi+$8#mgg2cYPGtiusTZg;y8d81oSg(g4CQEhxsOhzFsu&ux}~+vNGCaRAErU8&FA3 zbiWx4=?C5+6=%&#C^(?eUz3dc2(WaY96(mWF!)6pJkBfW`jprQqNq^`Ty!tEjoRH3%^j_th3=n{5#(@E5Hvz)0((w1juwS78&Vb#rhNw)H+ zNzQvLi{6m7S~#e=qt>t!#{}LKKt%}UMK{N-Q<{?UFA#E6N2rG^`>cew@HWHJeA&eC zPdL8PlL7bvy1Wg|X-rwxDX);M?AnlJ&VvJI3tHIy;WvXL@BeK0LMkD1six@_o2-rD zOad{U<@Y6QL#$T7dt@ltE=qXKw_PaPE=w?d+s9<1qV$`lX8U#4908v(Y$*$FP9SsB zBY-{#Hr(HpuBITD0={PGTu__yG+EJ&0={Kve3(Z`Ek0PNmC-NOFUFpmcxhI{8$A_obO2A0xLDC(5j9{Msfcg5@|2ImGP9EHl!71+!gb;mm3&Td(tM z4ap<7Fj@u computer = new ArrayList<>(); + computer = random.Computer(); + + boolean flag = false; + + ArrayList user = new ArrayList<>(); + + while() + } +} diff --git a/src/main/java/baseball/Random.java b/src/main/java/baseball/Random.java new file mode 100644 index 0000000000..61c276f4a1 --- /dev/null +++ b/src/main/java/baseball/Random.java @@ -0,0 +1,18 @@ +package baseball; + +import java.util.ArrayList; + +import camp.nextstep.edu.missionutils.Randoms; + +public class Random { + public static ArrayList Computer(){ + ArrayList arr = new ArrayList<>(); + while(arr.size() < 3) { + int random = Randoms.pickNumberInRange(1, 9); + if(!arr.contains(random)) { + arr.add(random); + } + } + return arr; + } +} From 05a6a5018869580d0e8558220885162700455322 Mon Sep 17 00:00:00 2001 From: junwoong2 <117076854+junwoong2@users.noreply.github.com> Date: Thu, 9 Nov 2023 14:17:34 +0900 Subject: [PATCH 03/13] finish --- bin/main/baseball/Application.class | Bin 843 -> 485 bytes src/main/java/baseball/Application.java | 13 +--- src/main/java/baseball/Check.java | 18 ----- .../baseball/Controller/Game_Service.java | 69 ++++++++++++++++++ .../baseball/Controller/Play_controller.java | 49 +++++++++++++ .../baseball/Controller/User_controller.java | 27 +++++++ src/main/java/baseball/Model/Computer.java | 32 ++++++++ .../java/baseball/Model/Game_function.java | 36 +++++++++ src/main/java/baseball/Model/User.java | 13 ++++ src/main/java/baseball/Random.java | 18 ----- .../java/baseball/View/SystemMessage.java | 29 ++++++++ src/test/java/baseball/ApplicationTest.java | 4 +- 12 files changed, 261 insertions(+), 47 deletions(-) delete mode 100644 src/main/java/baseball/Check.java create mode 100644 src/main/java/baseball/Controller/Game_Service.java create mode 100644 src/main/java/baseball/Controller/Play_controller.java create mode 100644 src/main/java/baseball/Controller/User_controller.java create mode 100644 src/main/java/baseball/Model/Computer.java create mode 100644 src/main/java/baseball/Model/Game_function.java create mode 100644 src/main/java/baseball/Model/User.java delete mode 100644 src/main/java/baseball/Random.java create mode 100644 src/main/java/baseball/View/SystemMessage.java diff --git a/bin/main/baseball/Application.class b/bin/main/baseball/Application.class index 5fa2ee0ba241e0b98de3e0ff21f28e1538c9e6b2..9f1002ccaa029d5cc6ad598d1d6c9c73fed725f3 100644 GIT binary patch delta 166 zcmX@j_LQ0H)W2Q(7#J9A8Kft2?NQ@PN-R!IO3ca8cg{#n&gNneVBiE1B0LPD3~Y=H ztjQqZ$*URV1q6Ih)lT+hDi8KxU;;u02AZ4}CA=<0SG>hU=gz zP??2Hj3%QrmD7$M8xIw@_RFS^8@MS@I!vO`#HdtYv(e15EQhpRY~i+p?Ij_))3H&J zk2|m}Y8|DV31v zkV;in2tg8qIf;!+DKkB&Vlka5Gq3PJepdgb-b_aq{b{WdWPhQ;*RfGUm9`I<#_J}N zbf8{o+wSth5bfDUPzDOcc>{91aZ0#5d<8rO&$ZSmO5bK~kGpl#h%4Ov^Sh6$e7U%W zby{rjSAtp4?K6}=o^r^}P~llS`ic6{cih_jfgOvPhsCTD4=8cD903niB5x7X=Ge(_ i@EA{Kf2wGp$t-35Y2hjJ?9y&4$t=%iH1=rAA@~Q3FTp|p diff --git a/src/main/java/baseball/Application.java b/src/main/java/baseball/Application.java index 46fdd2d6b9..ebf196cf93 100644 --- a/src/main/java/baseball/Application.java +++ b/src/main/java/baseball/Application.java @@ -1,15 +1,10 @@ package baseball; -import java.util.ArrayList; +import baseball.Controller.Play_controller; public class Application { public static void main(String[] args) { - // TODO: 프로그램 구현 - Random computer = new Random(); - ArrayList random = new ArrayList<>(); - random = computer.Computer(); - - System.out.println(random); + Play_controller controller = new Play_controller(); + controller.run(); } - -} +} \ No newline at end of file diff --git a/src/main/java/baseball/Check.java b/src/main/java/baseball/Check.java deleted file mode 100644 index ebbb9a0abc..0000000000 --- a/src/main/java/baseball/Check.java +++ /dev/null @@ -1,18 +0,0 @@ -package baseball; - -import java.util.ArrayList; - -public class Check { - public static void check() { - - Random random = new Random(); - ArrayList computer = new ArrayList<>(); - computer = random.Computer(); - - boolean flag = false; - - ArrayList user = new ArrayList<>(); - - while() - } -} diff --git a/src/main/java/baseball/Controller/Game_Service.java b/src/main/java/baseball/Controller/Game_Service.java new file mode 100644 index 0000000000..143397153e --- /dev/null +++ b/src/main/java/baseball/Controller/Game_Service.java @@ -0,0 +1,69 @@ +package baseball.Controller; + +import baseball.Model.Game_function; +import baseball.Model.User; +import baseball.Model.Computer; +import baseball.View.SystemMessage; + +import camp.nextstep.edu.missionutils.Console; + +public class Game_Service { + + int size; + Game_function game; + User user = new User(); + User_controller parser = new User_controller(); + SystemMessage systemMessage = new SystemMessage(); + + public void setGame(int size, int start, int end) { + this.size = size; + game = new Game_function(Computer.getRandomNumbers(size, start, end)); + } + + public void playGame() { + int strike = 0; + while (strike != 3) { + play(); + systemMessage.printScoreMessage(game.getBallCount(), game.getStrikeCount()); + strike = game.getStrikeCount(); + } + } + + private void play() { + game.initBaseBall(); + user.setUserNumbers(getUserNumber()); + computeScore(); + } + + private int[] getUserNumber() throws IllegalArgumentException { + SystemMessage.requestInputData(); + String input = Console.readLine(); + return parser.UserInput(input, size); + } + + private void computeScore() { + for (int i = 0; i < size; i++) { + compute(game.getGameNumbers(), user.getUserNumbers(), i); + } + } + + private void compute(int[] gameNumber, int[] userNumber, int index) { + int temp = -1; + for (int i = 0; i < gameNumber.length; i++) { + if (gameNumber[i] == userNumber[index]) { + temp = i; + break; + } + } + incCount(index, temp); + } + + private void incCount(int index, int temp) { + if (temp != index && temp != -1) { + game.incBallCount(); + } + if (temp == index) { + game.incStrikeCount(); + } + } +} \ No newline at end of file diff --git a/src/main/java/baseball/Controller/Play_controller.java b/src/main/java/baseball/Controller/Play_controller.java new file mode 100644 index 0000000000..81303d66a1 --- /dev/null +++ b/src/main/java/baseball/Controller/Play_controller.java @@ -0,0 +1,49 @@ +package baseball.Controller; + +import baseball.View.SystemMessage; +import camp.nextstep.edu.missionutils.Console; + +public class Play_controller { + final int SIZE = 3; + final int START_INCLUSIVE = 1; + final int END_INCLUSIVE = 9; + final int RETRY = 1; + final int GAME_OVER = 2; + + Game_Service gameService = new Game_Service(); + + public void run() throws IllegalArgumentException { + setGame(); + startGame(); + endGame(); + askRetry(); + } + + private void setGame() { + gameService.setGame(SIZE, START_INCLUSIVE, END_INCLUSIVE); + } + + private void startGame() throws IllegalArgumentException { + gameService.playGame(); + } + + private void endGame() { + SystemMessage.printGameOverMessage(); + } + + private void askRetry() throws IllegalArgumentException { + SystemMessage.printRetryMessage(); + if (getInputNum() == RETRY) { + run(); + } + } + + private int getInputNum() throws IllegalArgumentException { + int inputNum = Integer.parseInt(Console.readLine()); + + if (inputNum == 0 || inputNum > GAME_OVER) { + throw new IllegalArgumentException(); + } + return inputNum; + } +} \ No newline at end of file diff --git a/src/main/java/baseball/Controller/User_controller.java b/src/main/java/baseball/Controller/User_controller.java new file mode 100644 index 0000000000..aecfac91fd --- /dev/null +++ b/src/main/java/baseball/Controller/User_controller.java @@ -0,0 +1,27 @@ +package baseball.Controller; + +public class User_controller { + + public int[] UserInput(String input, int size) throws IllegalArgumentException { + checkSize(input, size); + return getParseInt(input, size); + } + + private void checkSize(String input, int size) throws IllegalArgumentException { + if (input.length() != size) { + throw new IllegalArgumentException(); + } + } + + private int[] getParseInt(String input, int size) throws IllegalArgumentException { + int[] parseInt = new int[size]; + + for (int i = 0; i < input.length(); i++) { + if (!('0' <= input.charAt(i) && input.charAt(i) <= '9')) { + throw new IllegalArgumentException(); + } + parseInt[i] = input.charAt(i) - '0'; + } + return parseInt; + } +} diff --git a/src/main/java/baseball/Model/Computer.java b/src/main/java/baseball/Model/Computer.java new file mode 100644 index 0000000000..4c9437bd67 --- /dev/null +++ b/src/main/java/baseball/Model/Computer.java @@ -0,0 +1,32 @@ +package baseball.Model; + +import camp.nextstep.edu.missionutils.Randoms; + +public class Computer { + + public static int[] getRandomNumbers(int size, int start, int end) { + int[] numbers = new int[3]; + + for (int i = 0; i < size; i++) { + numbers[i] = RandomNumber(numbers, start, end, i); + } + return numbers; + } + + private static int RandomNumber(int[] numbers, int start, int end, int i) { + int randomNumber = Randoms.pickNumberInRange(start, end); + while (!isSame(numbers, i, randomNumber)) { + randomNumber = Randoms.pickNumberInRange(start, end); + } + return randomNumber; + } + + private static Boolean isSame(int[] numbers, int i, int randomNumber) { + for (int j = 0; j < i; j++) { + if (numbers[j] == randomNumber) { + return false; + } + } + return true; + } +} \ No newline at end of file diff --git a/src/main/java/baseball/Model/Game_function.java b/src/main/java/baseball/Model/Game_function.java new file mode 100644 index 0000000000..aba46df11f --- /dev/null +++ b/src/main/java/baseball/Model/Game_function.java @@ -0,0 +1,36 @@ +package baseball.Model; + +public class Game_function { + int strikeCount; + int ballCount; + int[] gameNumbers; + + public Game_function(int[] numbers) { + gameNumbers = numbers; + } + + public void initBaseBall() { + strikeCount = 0; + ballCount = 0; + } + + public int getStrikeCount() { + return strikeCount; + } + + public int getBallCount() { + return ballCount; + } + + public int[] getGameNumbers() { + return gameNumbers; + } + + public void incStrikeCount() { + strikeCount += 1; + } + + public void incBallCount() { + ballCount += 1; + } +} \ No newline at end of file diff --git a/src/main/java/baseball/Model/User.java b/src/main/java/baseball/Model/User.java new file mode 100644 index 0000000000..13165e30c5 --- /dev/null +++ b/src/main/java/baseball/Model/User.java @@ -0,0 +1,13 @@ +package baseball.Model; + +public class User { + int[] userNumbers; + + public int[] getUserNumbers() { + return userNumbers; + } + + public void setUserNumbers(int[] userNumbers) { + this.userNumbers = userNumbers; + } +} \ No newline at end of file diff --git a/src/main/java/baseball/Random.java b/src/main/java/baseball/Random.java deleted file mode 100644 index 61c276f4a1..0000000000 --- a/src/main/java/baseball/Random.java +++ /dev/null @@ -1,18 +0,0 @@ -package baseball; - -import java.util.ArrayList; - -import camp.nextstep.edu.missionutils.Randoms; - -public class Random { - public static ArrayList Computer(){ - ArrayList arr = new ArrayList<>(); - while(arr.size() < 3) { - int random = Randoms.pickNumberInRange(1, 9); - if(!arr.contains(random)) { - arr.add(random); - } - } - return arr; - } -} diff --git a/src/main/java/baseball/View/SystemMessage.java b/src/main/java/baseball/View/SystemMessage.java new file mode 100644 index 0000000000..6a5fee65ae --- /dev/null +++ b/src/main/java/baseball/View/SystemMessage.java @@ -0,0 +1,29 @@ +package baseball.View; + +public class SystemMessage { + public static void requestInputData() { + System.out.print("숫자를 입력해 주세요 : "); + } + + public static void printRetryMessage() { + System.out.println("게임을 다시 시작하려면 1, 종료하려면 2를 입력하세요."); + } + public void printScoreMessage(int ball, int strike) { + if (ball == 0 && strike == 0) { + System.out.println("낫싱"); + } + if (ball == 0 && strike != 0) { + System.out.println(strike + "스트라이크"); + } + if (ball != 0 && strike == 0) { + System.out.println(ball + "볼"); + } + if (ball != 0 && strike != 0) { + System.out.println(ball + "볼 " + strike + "스트라이크"); + } + } + + public static void printGameOverMessage() { + System.out.println("3개의 숫자를 모두 맞히셨습니다! 게임 종료"); + } +} \ No newline at end of file diff --git a/src/test/java/baseball/ApplicationTest.java b/src/test/java/baseball/ApplicationTest.java index 3fa29fa67b..f8ec5c3607 100644 --- a/src/test/java/baseball/ApplicationTest.java +++ b/src/test/java/baseball/ApplicationTest.java @@ -22,8 +22,8 @@ class ApplicationTest extends NsTest { @Test void 예외_테스트() { - assertSimpleTest(() -> - assertThatThrownBy(() -> runException("1234")) + assertSimpleTest(() -> + assertThatThrownBy(() -> runException("1234")) .isInstanceOf(IllegalArgumentException.class) ); } From 9398b943c7cb49e47c48524f409fbea5d10f9614 Mon Sep 17 00:00:00 2001 From: junwoong2 <117076854+junwoong2@users.noreply.github.com> Date: Thu, 9 Nov 2023 14:21:48 +0900 Subject: [PATCH 04/13] finish --- src/main/java/baseball/Controller/Game_Service.java | 2 +- src/main/java/baseball/Controller/Play_controller.java | 6 +++--- src/main/java/baseball/Controller/User_controller.java | 4 ++-- src/main/java/baseball/Model/Computer.java | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/baseball/Controller/Game_Service.java b/src/main/java/baseball/Controller/Game_Service.java index 143397153e..3c99768664 100644 --- a/src/main/java/baseball/Controller/Game_Service.java +++ b/src/main/java/baseball/Controller/Game_Service.java @@ -17,7 +17,7 @@ public class Game_Service { public void setGame(int size, int start, int end) { this.size = size; - game = new Game_function(Computer.getRandomNumbers(size, start, end)); + game = new Game_function(Computer.computerNum(size, start, end)); } public void playGame() { diff --git a/src/main/java/baseball/Controller/Play_controller.java b/src/main/java/baseball/Controller/Play_controller.java index 81303d66a1..294bf7cc27 100644 --- a/src/main/java/baseball/Controller/Play_controller.java +++ b/src/main/java/baseball/Controller/Play_controller.java @@ -5,8 +5,8 @@ public class Play_controller { final int SIZE = 3; - final int START_INCLUSIVE = 1; - final int END_INCLUSIVE = 9; + final int START = 1; + final int END = 9; final int RETRY = 1; final int GAME_OVER = 2; @@ -20,7 +20,7 @@ public void run() throws IllegalArgumentException { } private void setGame() { - gameService.setGame(SIZE, START_INCLUSIVE, END_INCLUSIVE); + gameService.setGame(SIZE, START, END); } private void startGame() throws IllegalArgumentException { diff --git a/src/main/java/baseball/Controller/User_controller.java b/src/main/java/baseball/Controller/User_controller.java index aecfac91fd..5e0e60499f 100644 --- a/src/main/java/baseball/Controller/User_controller.java +++ b/src/main/java/baseball/Controller/User_controller.java @@ -4,7 +4,7 @@ public class User_controller { public int[] UserInput(String input, int size) throws IllegalArgumentException { checkSize(input, size); - return getParseInt(input, size); + return getNum(input, size); } private void checkSize(String input, int size) throws IllegalArgumentException { @@ -13,7 +13,7 @@ private void checkSize(String input, int size) throws IllegalArgumentException { } } - private int[] getParseInt(String input, int size) throws IllegalArgumentException { + private int[] getNum(String input, int size) throws IllegalArgumentException { int[] parseInt = new int[size]; for (int i = 0; i < input.length(); i++) { diff --git a/src/main/java/baseball/Model/Computer.java b/src/main/java/baseball/Model/Computer.java index 4c9437bd67..8fd184af15 100644 --- a/src/main/java/baseball/Model/Computer.java +++ b/src/main/java/baseball/Model/Computer.java @@ -4,7 +4,7 @@ public class Computer { - public static int[] getRandomNumbers(int size, int start, int end) { + public static int[] computerNum(int size, int start, int end) { int[] numbers = new int[3]; for (int i = 0; i < size; i++) { From c54b3d7d406a46aa9ed7950d03a8a8d857c960bc Mon Sep 17 00:00:00 2001 From: junwoong2 <117076854+junwoong2@users.noreply.github.com> Date: Thu, 9 Nov 2023 14:31:04 +0900 Subject: [PATCH 05/13] finish --- src/main/java/baseball/{ => View}/Application.java | 2 +- src/test/java/baseball/ApplicationTest.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) rename src/main/java/baseball/{ => View}/Application.java (90%) diff --git a/src/main/java/baseball/Application.java b/src/main/java/baseball/View/Application.java similarity index 90% rename from src/main/java/baseball/Application.java rename to src/main/java/baseball/View/Application.java index ebf196cf93..d59367f112 100644 --- a/src/main/java/baseball/Application.java +++ b/src/main/java/baseball/View/Application.java @@ -1,4 +1,4 @@ -package baseball; +package baseball.View; import baseball.Controller.Play_controller; diff --git a/src/test/java/baseball/ApplicationTest.java b/src/test/java/baseball/ApplicationTest.java index f8ec5c3607..ea6b613a3c 100644 --- a/src/test/java/baseball/ApplicationTest.java +++ b/src/test/java/baseball/ApplicationTest.java @@ -1,5 +1,6 @@ package baseball; +import baseball.View.Application; import camp.nextstep.edu.missionutils.test.NsTest; import org.junit.jupiter.api.Test; From db560d415713fecf84814711554684908802d959 Mon Sep 17 00:00:00 2001 From: junwoong2 <117076854+junwoong2@users.noreply.github.com> Date: Thu, 9 Nov 2023 14:55:51 +0900 Subject: [PATCH 06/13] finish --- .../java/baseball/Controller/User_controller.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/baseball/Controller/User_controller.java b/src/main/java/baseball/Controller/User_controller.java index 5e0e60499f..fa1a6ebb16 100644 --- a/src/main/java/baseball/Controller/User_controller.java +++ b/src/main/java/baseball/Controller/User_controller.java @@ -1,9 +1,13 @@ package baseball.Controller; +import java.util.HashSet; +import java.util.Set; + public class User_controller { public int[] UserInput(String input, int size) throws IllegalArgumentException { checkSize(input, size); + checkSame(input); return getNum(input, size); } @@ -13,6 +17,17 @@ private void checkSize(String input, int size) throws IllegalArgumentException { } } + private void checkSame(String input) throws IllegalArgumentException{ + Set charSet = new HashSet<>(); + for (int i = 0; i < input.length(); i++) { + char currentChar = input.charAt(i); + if (charSet.contains(currentChar)) { + throw new IllegalArgumentException(); + } + charSet.add(currentChar); + } + } + private int[] getNum(String input, int size) throws IllegalArgumentException { int[] parseInt = new int[size]; From dad2fb1d0f713df8bf383ae547c33ae0f77b4f35 Mon Sep 17 00:00:00 2001 From: junwoong2 <117076854+junwoong2@users.noreply.github.com> Date: Mon, 13 Nov 2023 16:32:01 +0900 Subject: [PATCH 07/13] . --- bin/baseball/Application.class | Bin 394 -> 0 bytes bin/baseball/ApplicationTest.class | Bin 1889 -> 0 bytes bin/main/baseball/Application.class | Bin 485 -> 0 bytes bin/main/baseball/Check.class | Bin 462 -> 0 bytes bin/main/baseball/Random.class | Bin 929 -> 0 bytes bin/test/baseball/ApplicationTest.class | Bin 3200 -> 0 bytes docs/README.md | 33 ++++++++++++++++++ .../Controller => Service}/Game_Service.java | 14 ++++---- src/main/java/baseball/Application.java | 10 ++++++ ...y_controller.java => Play_Controller.java} | 6 ++-- ...r_controller.java => User_Controller.java} | 2 +- .../Game_Domain.java} | 6 ++-- src/main/java/baseball/View/Application.java | 10 ------ .../java/baseball/View/RequestMessage.java | 11 ++++++ .../java/baseball/View/SystemMessage.java | 6 ---- src/test/java/baseball/ApplicationTest.java | 1 - 16 files changed, 70 insertions(+), 29 deletions(-) delete mode 100644 bin/baseball/Application.class delete mode 100644 bin/baseball/ApplicationTest.class delete mode 100644 bin/main/baseball/Application.class delete mode 100644 bin/main/baseball/Check.class delete mode 100644 bin/main/baseball/Random.class delete mode 100644 bin/test/baseball/ApplicationTest.class rename src/main/java/{baseball/Controller => Service}/Game_Service.java (83%) create mode 100644 src/main/java/baseball/Application.java rename src/main/java/baseball/Controller/{Play_controller.java => Play_Controller.java} (88%) rename src/main/java/baseball/Controller/{User_controller.java => User_Controller.java} (97%) rename src/main/java/baseball/{Model/Game_function.java => Domain/Game_Domain.java} (84%) delete mode 100644 src/main/java/baseball/View/Application.java create mode 100644 src/main/java/baseball/View/RequestMessage.java diff --git a/bin/baseball/Application.class b/bin/baseball/Application.class deleted file mode 100644 index b6ead2c6d325c5823703d2cce4c5b549a46c1ab1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 394 zcmZus!A`B`0k3H=4XaBA3=>3zOXg(F0l z+G=-2XpK+jgz%<%QVCkF#gT&-<6Y4&nmihj6*CM2_JQy1!1`}O^;qb~d`oIu>m{Xif;aV;22 zmP#av?Xx%Ry*6|r=xK;xU$FbrAn`!54i3?iiWi^D^L_MR7;Oo~4UU?|fnb2)H@>7z ArvLx| diff --git a/bin/baseball/ApplicationTest.class b/bin/baseball/ApplicationTest.class deleted file mode 100644 index 04b7e37c7ebc67a7a8b9cb7a5e9c3e8e78b7de75..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1889 zcmd5-O-~a+7=EV|T51)nAc$Y%$Dt%jFP=n6h|x$=Fo8mxU#Enfsl0a{rHCVxAvRb%Pu5-r{=(;APuww)|^24(Pk~dU^ zr=Xia&o=g^)=H=05J|kaD>XODZSV?pl;;b#>45rLm0j+ct2EPHs&OhjUujDn=J_~C zsVpsXy7lP}jMCMSdVnz;1Z;<_9Zckq8N;=$ALQ~N=#+^{8^c1aqKw)FpJT3VK(J&U zw>4Fvt;nXCtSE0P@XB0INVKXvqRHon>E$tcfAJC(((XG9Q(9J6|2hNhTyFrsiWKq+Wm}Rt>JTsBnt8G@W}~S}d^%eB8(= zu~z*u8A!w7EOf#V0{!{owuon}7P2}TiM*$Xb!ip1#89^caz*7Zca~`p*_$tuwk8aL zq2hi$HHwR0->!yhOX17qZ?9J8Hl8ibg==rZhtI>cM+8nz2hs|UPsoNa0*S|?PH1)v z@^%%YEgen60D;f#^woc@BRpKfClA7>>vJ2+tKrJ)jg|E@3=w$zk23p12@*(cDlZME z2`v6R%B^Ev6Vg%A2xC$Dw*}WsJGF%roJT3O z4k7~CNns4iyo4QLfC3)t_;UbA;@t^dXs7V$3ce*cXFfpsUM}+vvY*gOKo5=)25`L> z$7~A)MhRxP?N;GM)Q&;0XvoC=2BC`))c;X zwShz%Rsu>2jrNAwGEc;{)Z&AGCpptfa01$$t_K+OqMgaw6oup&dFylq=d~<*WObR6 z*dpt%-#)e}a?wDOGP?POV21wjf#6|9CwoJyVl>KuE*yBo@k>_c_dhz=r#=TJEqy>V KhC_-C9Q^=~tzSR@ diff --git a/bin/main/baseball/Check.class b/bin/main/baseball/Check.class deleted file mode 100644 index 8a70331dcb69a70f8b724dd0fbf666525d6c3f2d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 462 zcmY*VJx>Bb5Pf@mpD2i;mM0Yu3j^A~Fp5Yne!M z%aCcd1`OG*8VVN~l*-5<&rk_uA|95rQ0PY<#)6?1sEEe{uBENFVAhP~f((NHt{sM4 zw6U*}*3SM;Yo&{*G4!4iEfy+XiJ=#%*<8llNR@bVtw?@$<+-K)Yhw6|C+v(zlu=WW zc#T%$!W)WM7~xs>4eYw8;Mjh?&QNa#JIlV&G8uL3mTq4ybtLYk-N#Mub7>oK4mt!K z5pd{52cTG>%BRdI=h|x&-%{G8XlVkmN3pzpm$6S(2?u|}?X9Hyfy#63aE+rc>Ts}A OsHO@Ip$sP}clrx?z+sF4 diff --git a/bin/main/baseball/Random.class b/bin/main/baseball/Random.class deleted file mode 100644 index 23482a46b2f18f620fa9a2a9903f43784324f744..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 929 zcmZ`%+iuf95IvilB(r5A#FBx7&2RaUlfprZXk;s<>^RIJdTGw5j^ER zS1^=2zQf%e9!P~JhneV=3>oG+|CMbqH za^UeO4yeG|^r&`nb8YK4V=Rgy<;Suz2w!lM*jC(w|o2g$k}4xTb>Byx&*2VW5fY z)U8myA!gJ%TR8)gxN?fXxnMj742(jnCtG+h`qRedwA<5#XPD_m+}V4?N0S*Sbp1GR z!~?0Oq?nA|x)KSiAbK>MK#DAyD_S)|7VV7oZ1V{DPh)q1R^U;_g}HH(cVwjqZ+t=d`4JW#en2f#(vMMTHV(&+mf}&R8hMyl!wo`ZERaXh-yozoCcc}5ZqctJ^#er> N|%jGz~wKo)4$;I++^saotDSyn%;ZQJ=u4kbN0E(-~ZkI3&1X1 z6;Q>ndPsG&A=NOH-a^69v#P6G=78q70-_8pSv6l!Ol`t-T&zS2rBR zB}e6u!~GdzJ9SfcpJj+NH6Le)_F2PP91&DYSb`WsZAv$_LtcJJvj@~6Lt~IrR#r8R ztG3S9C1cbb)g6ZV)MCt%wE6FElf~;7ia%YP{&{k6=7$S|#p^eUSAHyB|AJx7QO|Vs zymnl7bb{?QP0RJeBGh#$%g!ld9ucMg1>MzbMJ?zGk02>iUStU?P{$x>6I#}DiRAvK z#hElO0ypBBS)NE`uaCl`OUAJZs|7s9uzXA%R~17wb4tJIYB|l8um<&X=(uWl+Tjs~ zRZacPsR}p3SceS))-$v|Ol5izK`b}Epw4j8?njRsb z1^As@z{a(ZC|#6lo$naAH z+cOWUx+$QU0L$4+yS8rT;&=*A3)sp~w~(?Vv_c`(<_Uo3KO9N`kmP5GhMFH5RvWi5 z#P?2QwSu2s0UZo0$|nwt+SVCfbrGG^5AEB#M0C@nt)o-K4hGgHf@B=&+|ey!7oYU( z5V4y!+T)a&UI}|RnFs~M*UwAXi+$8#mgg2cYPGtiusTZg;y8d81oSg(g4CQEhxsOhzFsu&ux}~+vNGCaRAErU8&FA3 zbiWx4=?C5+6=%&#C^(?eUz3dc2(WaY96(mWF!)6pJkBfW`jprQqNq^`Ty!tEjoRH3%^j_th3=n{5#(@E5Hvz)0((w1juwS78&Vb#rhNw)H+ zNzQvLi{6m7S~#e=qt>t!#{}LKKt%}UMK{N-Q<{?UFA#E6N2rG^`>cew@HWHJeA&eC zPdL8PlL7bvy1Wg|X-rwxDX);M?AnlJ&VvJI3tHIy;WvXL@BeK0LMkD1six@_o2-rD zOad{U<@Y6QL#$T7dt@ltE=qXKw_PaPE=w?d+s9<1qV$`lX8U#4908v(Y$*$FP9SsB zBY-{#Hr(HpuBITD0={PGTu__yG+EJ&0={Kve3(Z`Ek0PNmC-NOFUFpmcxhI{8$A_obO2A0xLDC(5j9{Msfcg5@|2ImGP9EHl!71+!gb;mm3&Td(tM z4ap<7Fj@u Date: Mon, 13 Nov 2023 16:33:13 +0900 Subject: [PATCH 08/13] . --- src/main/java/baseball/Controller/Play_Controller.java | 2 +- src/main/java/{ => baseball}/Service/Game_Service.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/main/java/{ => baseball}/Service/Game_Service.java (98%) diff --git a/src/main/java/baseball/Controller/Play_Controller.java b/src/main/java/baseball/Controller/Play_Controller.java index b0a218a606..5a4abf3fd1 100644 --- a/src/main/java/baseball/Controller/Play_Controller.java +++ b/src/main/java/baseball/Controller/Play_Controller.java @@ -1,6 +1,6 @@ package baseball.Controller; -import Service.Game_Service; +import baseball.Service.Game_Service; import baseball.View.RequestMessage; import baseball.View.SystemMessage; import camp.nextstep.edu.missionutils.Console; diff --git a/src/main/java/Service/Game_Service.java b/src/main/java/baseball/Service/Game_Service.java similarity index 98% rename from src/main/java/Service/Game_Service.java rename to src/main/java/baseball/Service/Game_Service.java index 3e9c3cd2fc..a80ac6dfc5 100644 --- a/src/main/java/Service/Game_Service.java +++ b/src/main/java/baseball/Service/Game_Service.java @@ -1,4 +1,4 @@ -package Service; +package baseball.Service; import baseball.Controller.User_Controller; import baseball.Domain.Game_Domain; From 3fccc49a52598878afc041fb9dc2e83a02a808e5 Mon Sep 17 00:00:00 2001 From: junwoong2 <117076854+junwoong2@users.noreply.github.com> Date: Thu, 16 Nov 2023 17:35:50 +0900 Subject: [PATCH 09/13] Application --- src/main/java/baseball/Application.java | 2 +- .../baseball/Controller/Play_Controller.java | 16 ++++++++-------- .../baseball/Controller/User_Controller.java | 2 +- src/main/java/baseball/Model/Computer.java | 3 +-- src/main/java/baseball/Service/Game_Service.java | 4 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/java/baseball/Application.java b/src/main/java/baseball/Application.java index bc1a6bb0fe..2c7a7fac49 100644 --- a/src/main/java/baseball/Application.java +++ b/src/main/java/baseball/Application.java @@ -5,6 +5,6 @@ public class Application { public static void main(String[] args) { Play_Controller controller = new Play_Controller(); - controller.run(); + controller.runGame(); } } \ No newline at end of file diff --git a/src/main/java/baseball/Controller/Play_Controller.java b/src/main/java/baseball/Controller/Play_Controller.java index 5a4abf3fd1..7c6cd2764b 100644 --- a/src/main/java/baseball/Controller/Play_Controller.java +++ b/src/main/java/baseball/Controller/Play_Controller.java @@ -6,15 +6,15 @@ import camp.nextstep.edu.missionutils.Console; public class Play_Controller { - final int SIZE = 3; - final int START = 1; - final int END = 9; - final int RETRY = 1; - final int GAME_OVER = 2; + private static final int NUM_SIZE = 3; + private static final int START = 1; + private static final int END = 9; + private static final int RETRY = 1; + private static final int GAME_OVER = 2; Game_Service gameService = new Game_Service(); - public void run() throws IllegalArgumentException { + public void runGame() throws IllegalArgumentException { setGame(); startGame(); endGame(); @@ -22,7 +22,7 @@ public void run() throws IllegalArgumentException { } private void setGame() { - gameService.setGame(SIZE, START, END); + gameService.setGame(NUM_SIZE, START, END); } private void startGame() throws IllegalArgumentException { @@ -36,7 +36,7 @@ private void endGame() { private void askRetry() throws IllegalArgumentException { RequestMessage.printRetryMessage(); if (getInputNum() == RETRY) { - run(); + runGame(); } } diff --git a/src/main/java/baseball/Controller/User_Controller.java b/src/main/java/baseball/Controller/User_Controller.java index 816d5aaec1..93f1d87c91 100644 --- a/src/main/java/baseball/Controller/User_Controller.java +++ b/src/main/java/baseball/Controller/User_Controller.java @@ -5,7 +5,7 @@ public class User_Controller { - public int[] UserInput(String input, int size) throws IllegalArgumentException { + public int[] checkUserInput(String input, int size) throws IllegalArgumentException { checkSize(input, size); checkSame(input); return getNum(input, size); diff --git a/src/main/java/baseball/Model/Computer.java b/src/main/java/baseball/Model/Computer.java index 8fd184af15..2070934478 100644 --- a/src/main/java/baseball/Model/Computer.java +++ b/src/main/java/baseball/Model/Computer.java @@ -4,9 +4,8 @@ public class Computer { - public static int[] computerNum(int size, int start, int end) { + public static int[] getComputerNum(int size, int start, int end) { int[] numbers = new int[3]; - for (int i = 0; i < size; i++) { numbers[i] = RandomNumber(numbers, start, end, i); } diff --git a/src/main/java/baseball/Service/Game_Service.java b/src/main/java/baseball/Service/Game_Service.java index a80ac6dfc5..2a0374889a 100644 --- a/src/main/java/baseball/Service/Game_Service.java +++ b/src/main/java/baseball/Service/Game_Service.java @@ -19,7 +19,7 @@ public class Game_Service { public void setGame(int size, int start, int end) { this.size = size; - game = new Game_Domain(Computer.computerNum(size, start, end)); + game = new Game_Domain(Computer.getComputerNum(size, start, end)); } public void playGame() { @@ -40,7 +40,7 @@ private void play() { private int[] getUserNumber() throws IllegalArgumentException { RequestMessage.requestInputData(); String input = Console.readLine(); - return parser.UserInput(input, size); + return parser.checkUserInput(input, size); } private void computeScore() { From e2000e57cc66817e02a0bd57b5d086c08d301224 Mon Sep 17 00:00:00 2001 From: junwoong2 <117076854+junwoong2@users.noreply.github.com> Date: Thu, 16 Nov 2023 17:35:50 +0900 Subject: [PATCH 10/13] refactor : change methods name --- src/main/java/baseball/Application.java | 2 +- .../baseball/Controller/Play_Controller.java | 16 ++++++++-------- .../baseball/Controller/User_Controller.java | 2 +- src/main/java/baseball/Model/Computer.java | 3 +-- src/main/java/baseball/Service/Game_Service.java | 4 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/java/baseball/Application.java b/src/main/java/baseball/Application.java index bc1a6bb0fe..2c7a7fac49 100644 --- a/src/main/java/baseball/Application.java +++ b/src/main/java/baseball/Application.java @@ -5,6 +5,6 @@ public class Application { public static void main(String[] args) { Play_Controller controller = new Play_Controller(); - controller.run(); + controller.runGame(); } } \ No newline at end of file diff --git a/src/main/java/baseball/Controller/Play_Controller.java b/src/main/java/baseball/Controller/Play_Controller.java index 5a4abf3fd1..7c6cd2764b 100644 --- a/src/main/java/baseball/Controller/Play_Controller.java +++ b/src/main/java/baseball/Controller/Play_Controller.java @@ -6,15 +6,15 @@ import camp.nextstep.edu.missionutils.Console; public class Play_Controller { - final int SIZE = 3; - final int START = 1; - final int END = 9; - final int RETRY = 1; - final int GAME_OVER = 2; + private static final int NUM_SIZE = 3; + private static final int START = 1; + private static final int END = 9; + private static final int RETRY = 1; + private static final int GAME_OVER = 2; Game_Service gameService = new Game_Service(); - public void run() throws IllegalArgumentException { + public void runGame() throws IllegalArgumentException { setGame(); startGame(); endGame(); @@ -22,7 +22,7 @@ public void run() throws IllegalArgumentException { } private void setGame() { - gameService.setGame(SIZE, START, END); + gameService.setGame(NUM_SIZE, START, END); } private void startGame() throws IllegalArgumentException { @@ -36,7 +36,7 @@ private void endGame() { private void askRetry() throws IllegalArgumentException { RequestMessage.printRetryMessage(); if (getInputNum() == RETRY) { - run(); + runGame(); } } diff --git a/src/main/java/baseball/Controller/User_Controller.java b/src/main/java/baseball/Controller/User_Controller.java index 816d5aaec1..93f1d87c91 100644 --- a/src/main/java/baseball/Controller/User_Controller.java +++ b/src/main/java/baseball/Controller/User_Controller.java @@ -5,7 +5,7 @@ public class User_Controller { - public int[] UserInput(String input, int size) throws IllegalArgumentException { + public int[] checkUserInput(String input, int size) throws IllegalArgumentException { checkSize(input, size); checkSame(input); return getNum(input, size); diff --git a/src/main/java/baseball/Model/Computer.java b/src/main/java/baseball/Model/Computer.java index 8fd184af15..2070934478 100644 --- a/src/main/java/baseball/Model/Computer.java +++ b/src/main/java/baseball/Model/Computer.java @@ -4,9 +4,8 @@ public class Computer { - public static int[] computerNum(int size, int start, int end) { + public static int[] getComputerNum(int size, int start, int end) { int[] numbers = new int[3]; - for (int i = 0; i < size; i++) { numbers[i] = RandomNumber(numbers, start, end, i); } diff --git a/src/main/java/baseball/Service/Game_Service.java b/src/main/java/baseball/Service/Game_Service.java index a80ac6dfc5..2a0374889a 100644 --- a/src/main/java/baseball/Service/Game_Service.java +++ b/src/main/java/baseball/Service/Game_Service.java @@ -19,7 +19,7 @@ public class Game_Service { public void setGame(int size, int start, int end) { this.size = size; - game = new Game_Domain(Computer.computerNum(size, start, end)); + game = new Game_Domain(Computer.getComputerNum(size, start, end)); } public void playGame() { @@ -40,7 +40,7 @@ private void play() { private int[] getUserNumber() throws IllegalArgumentException { RequestMessage.requestInputData(); String input = Console.readLine(); - return parser.UserInput(input, size); + return parser.checkUserInput(input, size); } private void computeScore() { From 848bfbe0d671a71a855b95fd0205f8fecb23557d Mon Sep 17 00:00:00 2001 From: Moonjunwoong Date: Fri, 17 Nov 2023 21:36:52 +0900 Subject: [PATCH 11/13] refactor : rename methods --- src/main/java/baseball/Domain/Game_Domain.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/baseball/Domain/Game_Domain.java b/src/main/java/baseball/Domain/Game_Domain.java index 2b5ae82cfd..7481ba8bf5 100644 --- a/src/main/java/baseball/Domain/Game_Domain.java +++ b/src/main/java/baseball/Domain/Game_Domain.java @@ -4,7 +4,6 @@ public class Game_Domain { int strikeCount; int ballCount; int[] gameNumbers; - public Game_Domain(int[] numbers) { gameNumbers = numbers; } From 6db4991f1162fb326685a3b2313f91b260e4005d Mon Sep 17 00:00:00 2001 From: Moonjunwoong Date: Fri, 17 Nov 2023 21:40:02 +0900 Subject: [PATCH 12/13] =?UTF-8?q?docs=20:=20=EA=B5=AC=ED=98=84=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=84=A4=EB=AA=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 5f334bbd61..52c3d810a3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -9,7 +9,7 @@ - 1~9사이의 숫자 - 3개를 입력받음 -- 예외 ( IllegalArgumentException 발생 후 종료 ) +- 예외 처리 ( IllegalArgumentException 발생 후 종료 ) - 3개가 아닌 경우 - 중복되는 숫자가 있을 경우 - 1~9가 아닐 경우 From c4d98401925f96bef16cada170bfb19a0c6d7b41 Mon Sep 17 00:00:00 2001 From: Moonjunwoong Date: Fri, 17 Nov 2023 21:43:01 +0900 Subject: [PATCH 13/13] refactor : rename methods name --- src/main/java/baseball/Model/User.java | 2 -- src/main/java/baseball/View/RequestMessage.java | 1 - src/main/java/baseball/View/SystemMessage.java | 2 -- 3 files changed, 5 deletions(-) diff --git a/src/main/java/baseball/Model/User.java b/src/main/java/baseball/Model/User.java index 13165e30c5..be751f28e7 100644 --- a/src/main/java/baseball/Model/User.java +++ b/src/main/java/baseball/Model/User.java @@ -2,11 +2,9 @@ public class User { int[] userNumbers; - public int[] getUserNumbers() { return userNumbers; } - public void setUserNumbers(int[] userNumbers) { this.userNumbers = userNumbers; } diff --git a/src/main/java/baseball/View/RequestMessage.java b/src/main/java/baseball/View/RequestMessage.java index c7d00aa3f7..8d216fe63c 100644 --- a/src/main/java/baseball/View/RequestMessage.java +++ b/src/main/java/baseball/View/RequestMessage.java @@ -4,7 +4,6 @@ public class RequestMessage { public static void requestInputData() { System.out.print("숫자를 입력해 주세요 : "); } - public static void printRetryMessage() { System.out.println("게임을 다시 시작하려면 1, 종료하려면 2를 입력하세요."); } diff --git a/src/main/java/baseball/View/SystemMessage.java b/src/main/java/baseball/View/SystemMessage.java index b085ffa318..39959f002b 100644 --- a/src/main/java/baseball/View/SystemMessage.java +++ b/src/main/java/baseball/View/SystemMessage.java @@ -1,7 +1,6 @@ package baseball.View; public class SystemMessage { - public void printScoreMessage(int ball, int strike) { if (ball == 0 && strike == 0) { System.out.println("낫싱"); @@ -16,7 +15,6 @@ public void printScoreMessage(int ball, int strike) { System.out.println(ball + "볼 " + strike + "스트라이크"); } } - public static void printGameOverMessage() { System.out.println("3개의 숫자를 모두 맞히셨습니다! 게임 종료"); }