From 424212143a1ed5d9ce3394bfd17d06b6adf48b59 Mon Sep 17 00:00:00 2001 From: Eithea Date: Thu, 22 Dec 2022 11:33:54 +0900 Subject: [PATCH 01/10] docs: add a feature list --- README.md | 71 ++++++++++++++++++++++++++++++++++++++++ src/main/.DS_Store | Bin 0 -> 6148 bytes src/main/java/.DS_Store | Bin 0 -> 6148 bytes src/test/.DS_Store | Bin 0 -> 6148 bytes src/test/java/.DS_Store | Bin 0 -> 6148 bytes 5 files changed, 71 insertions(+) create mode 100644 src/main/.DS_Store create mode 100644 src/main/java/.DS_Store create mode 100644 src/test/.DS_Store create mode 100644 src/test/java/.DS_Store diff --git a/README.md b/README.md index fcf3f057..8bc82098 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,74 @@ ## 과제 제출 과정 * [과제 제출 방법](https://github.com/next-step/nextstep-docs/tree/master/ent-precourse) + + +## 기능 목록 + + +### 1. GameRule : 숫자야구 게임 규칙상의 조건과 절차 + + - numbers 조건 + - length 3 + - letter range 1 ~ 9 + - letter 중복 없음 + + - 2 numbers A, B 대조 + - a in A is in B => ball += 1 + - ai = bi => strike += 1 + - ball -= strike + + - 게임 결과 생성 + - 스트라이크와 볼의 갯수 + - 3스트라이크시 게임 종료 명시 + + +### 2. UI : 입출력을 담당하는 인터페이스 + + - numbers 입력 + - string 입력 받기 + - GameRule을 참조하여 올바른 입력인지 검증하기 + - 올바른 입력일 시 string을 array로 변환하여 리턴 + + - 인게임 결과 출력 + - 인자로 받은 스트라이크 볼 갯수를 자연어로 번역 + - 0인 경우 생략 + - 둘 모두 0일 경우 낫싱 + - 인게임 반복 여부 리턴 + - 3 스트라이크일 경우 False + - 그 외 True + + - 게임 종료 여부 입력 + - 인게임 종료 알림 출력 + - string 입력 루프 + - 잘못된 입력인 경우 리로드 + - 게임 종료 여부 리턴 + - 1일 경우 False + - 2일 경우 True + + +### 3. Computer : 인게임 상대 역할 + - 자신의 numbers 생성 + - 새 게임 시작을 전달받았을 때 실행 + - GameRule을 참조하여 numbers 필드 갱신 + - 인게임 결과 전달 + - numbers를 전달받았을 때 실행 + - GameRule의 게임 결과 생성 메소드를 이용하여 인게임 결과 받기 + - 인게임 결과 리턴 + + +### 4. Control : 게임 흐름 제어 + + - 객체 생성, 게임 루프 시작 + - 게임 루프 + - Computer에게 새 게임 시작 알리기 + - 인게임 루프 시작 + - 인게임 루프 + - UI 메소드 호출하여 numbers 받기 + - numbers를 Computer에게 전달하여 인게임 결과 받기 + - 인게임 결과를 인자로 UI 메소드 호출하여 인게임 반복 여부 받기 + - 인게임 반복 여부에 따라 루프 반복 혹은 탈출 + - 인게임 루프 탈출 = 게임 종료 + - UI 메소드 호출하여 게임 재시작 여부 받기 + - 게임 재시작 여부에 따라 루프 반복 혹은 탈출 + - 게임 루프 탈출 = 프로세스 종료 diff --git a/src/main/.DS_Store b/src/main/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a04e17d75e26f1dcc09249e4ba372bd1c623d405 GIT binary patch literal 6148 zcmeHK!AiqG5Z!I7O(;SS3VI88E!x&<5ic>;gI6PZP^pP28jab~r0t;;a@Qa7NBkX~ z+1(VhdJ;s+49vdG?97IF8+I~`G42e524hvmm;s7dFk$#ca2<6{3ffWx2y0vKQe+}CKYyI`^*O)#{U}V*di{+TilwFHvQaiF z#w2!0#Bq`@sT5v^8c5<<$X$ zYykjEV3q=N`Rfm8p#jj=m?;Dc2v?ziDwOLMgX_+Lt8iGiwST5ig)=VS4EyLebKRkE z-FR?Ix-)Joq>&gP20k-@y&p&w>;Li3{l9dgffyhL7Lx&9>bM;Ta?`bSE=#Pn7U&Hq q3i@RVXCW|=r5Jp%6t9Cy0lS40KwD#`5G)|{BOqy@ff)Ex20j37g;ePP literal 0 HcmV?d00001 diff --git a/src/main/java/.DS_Store b/src/main/java/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0;gI6PZP^pP28jab~r0t;;a@Qa7NBkX~ z+1(VhdJ;s+49vdG?97IF8+I~`G42e524hvmm;s7dFk$#ca2<6{3ffWx2y0vKQe+}CKYyI`^*O)#{U}V*di{+TilwFHvQaiF z#w2!0#Bq`@sT5v^8c5<<$X$ zYykjEV3q=N`Rfm8p#jj=m?;Dc2v?ziDwOLMgX_+Lt8iGiwST5ig)=VS4EyLebKRkE z-FR?Ix-)Joq>&gP20k-@y&p&w>;Li3{l9dgffyhL7Lx&9>bM;Ta?`bSE=#Pn7U&Hq q3i@RVXCW|=r5Jp%6t9Cy0lS40KwD#`5G)|{BOqy@ff)Ex20j37g;ePP literal 0 HcmV?d00001 diff --git a/src/test/java/.DS_Store b/src/test/java/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..fb438319b70c9a88ef8010f2323985a652c25cc2 GIT binary patch literal 6148 zcmeHKF-`+P474Fgk!VsIGAhcECmn6WLS)9H#7X`-=Y z&#uq2o15Yso0+dq`zN!NnJwW&`(l_HpVKFHQyB-samMG%;ker#j@wD?T!P#?d$$ie z*?z?5Px^*G{)WvRpu7~20#ZN Date: Thu, 22 Dec 2022 11:59:36 +0900 Subject: [PATCH 02/10] feat: implement GameRule that has basaball rule --- .gitignore | 1 + src/main/.DS_Store | Bin 6148 -> 6148 bytes src/main/java/.DS_Store | Bin 6148 -> 6148 bytes src/main/java/game/.DS_Store | Bin 0 -> 6148 bytes src/main/java/game/GameRule.java | 47 +++++++++++++++++++++++++++++++ src/test/java/.DS_Store | Bin 6148 -> 6148 bytes 6 files changed, 48 insertions(+) create mode 100644 src/main/java/game/.DS_Store create mode 100644 src/main/java/game/GameRule.java diff --git a/.gitignore b/.gitignore index 249cf086..24b2196e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ HELP.md .gradle build/ +bin/ !gradle/wrapper/gradle-wrapper.jar !**/src/main/** !**/src/test/** diff --git a/src/main/.DS_Store b/src/main/.DS_Store index a04e17d75e26f1dcc09249e4ba372bd1c623d405..1a1a2ce96b4fa86a85777facfe2033866e3390da 100644 GIT binary patch delta 488 zcmZoMXfc=|#>B!ku~2NHo+2a5#(>?7iw&5W7+E&+FtIY$XC{{wB<18MF)%PrNh-+6 zEG{uHxW~xE%)-jX&cVsW&BM#bFCfS-#4ju?A}S^>E*UQ%oRpZHonDk*nwR37pOatY zlvA1-k(r#I7o1s@8c~v3Q37Jb3kad93rbCiLkNXb768@Miy%b6hPfA|rshSb7iFgS zr==CAmP8=2BV&p)^2Bz*QqQt!PRHw?= zoW!Km9RED0{F0LV+;{z delta 69 zcmZoMXfc=|#>B)qu~2NHo+2aj#(>?7jLe&PSXdc1?`891+^oQ{hIunP2R{c;(Plx8 X@640=MI1R8fPj&Kfn{@q$QotN_7>Du_3Yn0b?#=iT>fXP({J*+B?lvr!pCNJj{1 z&=@9qq5Fj}KWj&%OInx{vl_D=Eju1{;F=Xwq8LyN{M!t$wVOayWTP4)ht}_H@Ll`P zg-@a#=QP8*T<33`y61*bF82Xyv;dxD^5+YY$w%LYpRS_?3|7TEd|vwPZ;j+1(w_Pvu9AiLt4@QDgV! zcy83l-(dLREwAR&=Yn?(A0{sS5@UD)N_#?Xd0S2h@5dAR6i+DG+jpja zAf=y84W`oR%+R^v;gOP_cI@(2HDH6Bp&kuPuR)gGGW9L@DOrxllZYuLeeh7+0;xPa zFfH!XAtrNR;I-}sg!rq~z^%+}Y=k6Q?$B4(LSSrlobkW z1esWqh!@#7lgVu1p0sG_GMYw3bRRkBF?xpf(M$9iy+!ZQNAwwe#TfVEG#PLXnpgP6CUuED27;xHg delta 62 zcmZoMXfc=|#>AjHu~2NHo+2v)5HM~`T*bUufrFi8Gb@K62T*deAjfy+$^0UUjEs{_ QMU*G|^KfjA5m~_u0KiTTI{*Lx diff --git a/src/main/java/game/.DS_Store b/src/main/java/game/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..87fa658f2b061cff540362c70c6c6778add2fb85 GIT binary patch literal 6148 zcmeHKJx{|>3_L@JN(iYVoU0CC227}qgN5Su56UE!F>49${COsdt0VM%AcRb5v&CMF#gC-XjavekrQ zaXRxY%3)oiq7;wB)qu~2NHo+2aj!~pA!7aACWj2_*3R)%7R5{6QS6o$&A^5TM|octsP z28NwU1v#0;B?bo97@3$^SlQS)*g3d4VuLgC%Y#c2OG=BK5{sfiypa6-oFo`KF)1uF zwLD%x#5q5&Br!8DwFs;sGbI(MBqlsFFD1X+DZex?r5LO?7$}hql;Pmy;EWfLtgbdP zF*ngsFf}x<)lsOnG&0apFflf(t>xqpRo1r-iqFo;&CBlwx()~!86h+SFO-H+JwOJM zpUQ%Z@^bR?(t)Ck8xKBV+04$t&jAdJjR(IoPv#fV6#?l3nbiQH!NzV55!t{zv4I5u Dm)uai delta 72 zcmZoMXfc=|#>CJzu~2NHo+2aT!~knX#>qTPx|_|IFS2ZQV6J7_%+A5j0aUWtkoi0F aWPTA{PDTa>h66y%FxiGjdUK4(5@rCSJP~35 From 57af06cbfd58d5b2b7e7b2a08fb200a0a590fb3d Mon Sep 17 00:00:00 2001 From: Eithea Date: Thu, 22 Dec 2022 12:01:44 +0900 Subject: [PATCH 03/10] feat: implement UI responsible for IO and verification --- src/main/java/game/UI.java | 111 +++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 src/main/java/game/UI.java diff --git a/src/main/java/game/UI.java b/src/main/java/game/UI.java new file mode 100644 index 00000000..1361114c --- /dev/null +++ b/src/main/java/game/UI.java @@ -0,0 +1,111 @@ +package game; + +import java.util.Scanner; +import java.util.HashSet; + +public class UI { + private GameRule gameRule; + private Scanner scanner; + + public UI(GameRule gameRule) { + this.gameRule = gameRule; + this.scanner = new Scanner(System.in); + } + + private boolean verifyNumbersLength(String input) { + return input.length() == gameRule.numbersLengh; + } + + private boolean verifyNumbersRangeOfLetter(int letter) { + boolean isInRange = false; + for (int num : gameRule.numbersRange) { + isInRange = isInRange || letter == num; + } + return isInRange; + } + + private boolean verifyNumbersRange(String input) { + boolean isCorrect = true; + for (int i = 0; i < gameRule.numbersLengh; i++) { + isCorrect = isCorrect && this.verifyNumbersRangeOfLetter(input.charAt(i) - '0'); + } + return isCorrect; + } + + private boolean verifyNumbersDuplication(String input) { + boolean isCorrect = true; + HashSet appearedSet = new HashSet(); + for (int i = 0; i < gameRule.numbersLengh; i++) { + Character letter = input.charAt(i); + isCorrect = isCorrect && appearedSet.add(letter); + } + return isCorrect; + } + + private boolean verifyNumbers(String input) { + if (!this.verifyNumbersLength(input)) + return false; + if (!this.verifyNumbersRange(input)) + return false; + if (!this.verifyNumbersDuplication(input)) + return false; + return true; + } + + private int[] parseNumbers(String input) { + int[] numbers = new int[gameRule.numbersLengh]; + for (int i = 0; i < gameRule.numbersLengh; i++) { + numbers[i] = input.charAt(i) -'0'; + } + return numbers; + } + + public int[] getUserNumbers() { + System.out.print("숫자를 입력해주세요 : "); + String input = scanner.nextLine(); + boolean verification = this.verifyNumbers(input); + while (!verification) { + System.out.print("올바른 조건의 숫자를 입력해주세요 : "); + input = scanner.nextLine(); + verification = this.verifyNumbers(input); + } + return this.parseNumbers(input); + } + + public void printResult(GameRule.Result result) { + if (result.strike == 0 && result.ball == 0) { + System.out.println("낫싱"); + return; + } + if (result.strike > 0) + System.out.print(result.strike + " 스트라이크 "); + if (result.ball > 0) + System.out.print(result.ball + " 볼"); + System.out.println(); + } + + private boolean verifyEndingStatus(String input) { + if (input.equals("1") || input.equals("2")) + return true; + return false; + } + + private boolean parseEndingStatus(String input) { + if (input.equals("2")) + return true; + return false; + } + + public boolean getEndingStatus() { + System.out.println("3개의 숫자를 모두 맞히셨습니다! 게임 종료"); + System.out.println("게임을 새로 시작하려면 1, 종료하려면 2를 입력하세요."); + String input = scanner.nextLine(); + boolean verification = this.verifyEndingStatus(input); + if (!verification) { + System.out.println("게임을 새로 시작하려면 1, 종료하려면 2를 입력하세요."); + input = scanner.nextLine(); + verification = this.verifyEndingStatus(input); + } + return this.parseEndingStatus(input); + } +} From b7d57792f660852e75089a1e93a7b89c1836ac5e Mon Sep 17 00:00:00 2001 From: Eithea Date: Thu, 22 Dec 2022 12:03:50 +0900 Subject: [PATCH 04/10] feat: implement Computer that act as an in-game opponent --- src/main/java/game/.DS_Store | Bin 6148 -> 6148 bytes src/main/java/game/Computer.java | 37 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/main/java/game/Computer.java diff --git a/src/main/java/game/.DS_Store b/src/main/java/game/.DS_Store index 87fa658f2b061cff540362c70c6c6778add2fb85..90081baa19fa18d8a216a375e4a689fd63f2a2b5 100644 GIT binary patch delta 147 zcmZoMXfc=|#>B`mu~2NHo}wT#0|Nsi1A_nqLn%WELn=ej#02e$4;n;4;=Byb4EYSX z38BHLzm4t@@xof|KH WXP(S2V#oosk)Z*IH+zWeVFmzY;3*;i delta 93 zcmZoMXfc=|#>CJ*u~2NHo}wTl0|NsP3otMQF_bdoFr-dQ&}L+u?8d0e8wr%M{SO73 oH!_B?O+LW*dNVr*KL=1hP~bcBWPTAtMuy2YJkpzEL{=~Z0Lvg8cmMzZ diff --git a/src/main/java/game/Computer.java b/src/main/java/game/Computer.java new file mode 100644 index 00000000..553dc61a --- /dev/null +++ b/src/main/java/game/Computer.java @@ -0,0 +1,37 @@ +package game; + +import java.util.Random; +import java.util.HashSet; + +public class Computer { + private GameRule gameRule; + private Random random; + private int[] numbers; + + public Computer(GameRule gameRule) { + this.gameRule = gameRule; + this.random = new Random(); + this.numbers = new int[gameRule.numbersLengh]; + } + + private int getNewNum(HashSet appearedSet) { + Integer randomNum = gameRule.numbersRange[random.nextInt(gameRule.numbersRange.length)]; + boolean isNew = appearedSet.add(randomNum); + while (!isNew) { + randomNum = gameRule.numbersRange[random.nextInt(gameRule.numbersRange.length)]; + isNew = appearedSet.add(randomNum); + } + return randomNum; + } + + public void updateNumbers() { + HashSet appearedSet = new HashSet(); + for (int i = 0; i < gameRule.numbersLengh; i++) { + numbers[i] = this.getNewNum(appearedSet); + } + } + + public GameRule.Result getResult(int[] inputNumbers) { + return gameRule.judgeResult(inputNumbers, numbers); + } +} From 5a43bbb3055f94be4bc63de5a4e5ae4f269944a6 Mon Sep 17 00:00:00 2001 From: Eithea Date: Thu, 22 Dec 2022 12:05:03 +0900 Subject: [PATCH 05/10] feat: implement Control that control the game flow --- src/main/java/game/Control.java | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/game/Control.java diff --git a/src/main/java/game/Control.java b/src/main/java/game/Control.java new file mode 100644 index 00000000..5a7606d7 --- /dev/null +++ b/src/main/java/game/Control.java @@ -0,0 +1,40 @@ +package game; + +public class Control { + private GameRule gameRule; + private UI ui; + private Computer computer; + + public Control() { + this.gameRule = new GameRule(); + this.ui = new UI(gameRule); + this.computer = new Computer(gameRule); + } + + private boolean inGameLoop() { + int[] numbers = ui.getUserNumbers(); + GameRule.Result result = computer.getResult(numbers); + ui.printResult(result); + if (result.isEnd) + return true; + return false; + } + + private boolean gameLoop() { + boolean isEnd = false; + computer.updateNumbers(); + while (!isEnd) { + isEnd = this.inGameLoop(); + } + if (ui.getEndingStatus()) + return true; + return false; + } + + public void start() { + boolean isEnd = false; + while (!isEnd) { + isEnd = this.gameLoop(); + } + } +} \ No newline at end of file From 00461763ea5ac92fef71d84e44d7c592c1b63409 Mon Sep 17 00:00:00 2001 From: Eithea Date: Thu, 22 Dec 2022 12:06:20 +0900 Subject: [PATCH 06/10] feat: static main --- src/main/java/.DS_Store | Bin 6148 -> 6148 bytes src/main/java/Main.java | 8 ++++++++ src/main/java/game/.DS_Store | Bin 6148 -> 6148 bytes 3 files changed, 8 insertions(+) create mode 100644 src/main/java/Main.java diff --git a/src/main/java/.DS_Store b/src/main/java/.DS_Store index d27ba188b6a07101b2a14801e5f5d1f65c10fea5..9b0de2098c2ea02d25da5372bff6ff3af77dbf47 100644 GIT binary patch delta 75 zcmZoMXfc@J&&atkU^g=(=Vl%j3ub*z2499mhD?S$20ex>Aghca(K9DMIVmSUiGhJZ V0EpKEvEF|um{>SvGdss$egNn=7!?2j delta 27 jcmZoMXfc@J&&aVcU^g=($7UWD3+9O>hc~lx{N)D#cDD$v diff --git a/src/main/java/Main.java b/src/main/java/Main.java new file mode 100644 index 00000000..8fd97a2b --- /dev/null +++ b/src/main/java/Main.java @@ -0,0 +1,8 @@ +import game.Control; + +public class Main { + public static void main(String[] args){ + Control control = new Control(); + control.start(); + } +} diff --git a/src/main/java/game/.DS_Store b/src/main/java/game/.DS_Store index 90081baa19fa18d8a216a375e4a689fd63f2a2b5..64d5f6e1a59394e4ca54b550211eb99846ef84ba 100644 GIT binary patch delta 49 zcmZoMXfc@J&&V<{U^gSnWFAIaejWyAhJ1!Rh7yJ%Ae}Q=fl-pNd$SeeRJP6R9Dn%% DG)@e6 delta 30 mcmZoMXfc@J&&WJ6U^gT4WFAJ_&5ew0Y!e$SHnVg5 Date: Thu, 22 Dec 2022 12:07:53 +0900 Subject: [PATCH 07/10] test: add test for game result --- src/test/.DS_Store | Bin 6148 -> 6148 bytes src/test/java/.DS_Store | Bin 6148 -> 6148 bytes src/test/java/game/UnitTest.java | 80 +++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 src/test/java/game/UnitTest.java diff --git a/src/test/.DS_Store b/src/test/.DS_Store index a04e17d75e26f1dcc09249e4ba372bd1c623d405..1a1a2ce96b4fa86a85777facfe2033866e3390da 100644 GIT binary patch delta 488 zcmZoMXfc=|#>B!ku~2NHo+2a5#(>?7iw&5W7+E&+FtIY$XC{{wB<18MF)%PrNh-+6 zEG{uHxW~xE%)-jX&cVsW&BM#bFCfS-#4ju?A}S^>E*UQ%oRpZHonDk*nwR37pOatY zlvA1-k(r#I7o1s@8c~v3Q37Jb3kad93rbCiLkNXb768@Miy%b6hPfA|rshSb7iFgS zr==CAmP8=2BV&p)^2Bz*QqQt!PRHw?= zoW!Km9RED0{F0LV+;{z delta 69 zcmZoMXfc=|#>B)qu~2NHo+2aj#(>?7jLe&PSXdc1?`891+^oQ{hIunP2R{c;(Plx8 X@640=MI1R8fPj&Kfn{@q$QotB!ku~2NHo}wrl0|Nsi1A_pAXHI@{QcivnkT0;=ka;4Yd;S6OgTUQT{qI#31UW*(+jOqK18w-u UJegm_kppNs6UcB)qu~2NHo}w@_0|Nsi1A_nqL#1aP!R hWZulq!OsEIuvw7fJM(0I5l0T77LXp6%@HDNm;nno5-tD$ diff --git a/src/test/java/game/UnitTest.java b/src/test/java/game/UnitTest.java new file mode 100644 index 00000000..00b1915e --- /dev/null +++ b/src/test/java/game/UnitTest.java @@ -0,0 +1,80 @@ +package game; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +public class UnitTest { + @Test + void gameRule_can_judgeResult() { + GameRule gameRule = new GameRule(); + int[] numbersTarget = {1,2,3}; + int[] numbersTestCase; + GameRule.Result result; + + // 3 strike + numbersTestCase = new int[]{1,2,3}; + result = gameRule.judgeResult(numbersTarget, numbersTestCase); + assertEquals(3, result.strike); + assertEquals(0, result.ball); + assertTrue(result.isEnd); + + // 2 strike + numbersTestCase = new int[]{1,2,4}; + result = gameRule.judgeResult(numbersTarget, numbersTestCase); + assertEquals(2, result.strike); + assertEquals(0, result.ball); + assertFalse(result.isEnd); + + // 1 strike 2 ball + numbersTestCase = new int[]{1,3,2}; + result = gameRule.judgeResult(numbersTarget, numbersTestCase); + assertEquals(1, result.strike); + assertEquals(2, result.ball); + assertFalse(result.isEnd); + + // 1 strike 1 ball + numbersTestCase = new int[]{1,3,4}; + result = gameRule.judgeResult(numbersTarget, numbersTestCase); + assertEquals(1, result.strike); + assertEquals(1, result.ball); + assertFalse(result.isEnd); + + // 1 strike + numbersTestCase = new int[]{1,4,5}; + result = gameRule.judgeResult(numbersTarget, numbersTestCase); + assertEquals(1, result.strike); + assertEquals(0, result.ball); + assertFalse(result.isEnd); + + // 3 ball + numbersTestCase = new int[]{2,3,1}; + result = gameRule.judgeResult(numbersTarget, numbersTestCase); + assertEquals(0, result.strike); + assertEquals(3, result.ball); + assertFalse(result.isEnd); + + // 2 ball + numbersTestCase = new int[]{2,1,4}; + result = gameRule.judgeResult(numbersTarget, numbersTestCase); + assertEquals(0, result.strike); + assertEquals(2, result.ball); + assertFalse(result.isEnd); + + // 1 ball + numbersTestCase = new int[]{2,4,5}; + result = gameRule.judgeResult(numbersTarget, numbersTestCase); + assertEquals(0, result.strike); + assertEquals(1, result.ball); + assertFalse(result.isEnd); + + // nothing + numbersTestCase = new int[]{4,5,6}; + result = gameRule.judgeResult(numbersTarget, numbersTestCase); + assertEquals(0, result.strike); + assertEquals(0, result.ball); + assertFalse(result.isEnd); + } +} From 61e75617c0384d391b6bcd0859abbc0f580ef7bb Mon Sep 17 00:00:00 2001 From: Eithea Date: Thu, 22 Dec 2022 12:19:01 +0900 Subject: [PATCH 08/10] chore: delete DS_Store --- src/main/.DS_Store | Bin 6148 -> 6148 bytes src/main/java/.DS_Store | Bin 6148 -> 0 bytes src/main/java/game/.DS_Store | Bin 6148 -> 0 bytes src/test/.DS_Store | Bin 6148 -> 6148 bytes src/test/java/.DS_Store | Bin 6148 -> 0 bytes 5 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/main/java/.DS_Store delete mode 100644 src/main/java/game/.DS_Store delete mode 100644 src/test/java/.DS_Store diff --git a/src/main/.DS_Store b/src/main/.DS_Store index 1a1a2ce96b4fa86a85777facfe2033866e3390da..850b6d07cb38b92f0b205e593a2f4aecd7eb893a 100644 GIT binary patch delta 21 ccmZoMXffDukcGp*!dOSa$k=l8Nfv8i07=~jIRF3v delta 21 ccmZoMXffDukcGp<+(bvg)X;qMNfv8i07?!9JOBUy diff --git a/src/main/java/.DS_Store b/src/main/java/.DS_Store deleted file mode 100644 index 9b0de2098c2ea02d25da5372bff6ff3af77dbf47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}*0S6n_I%c0uS$i--r^q%qNiV8H@09IU0r5Mv-LL5N`8ZI`mL-Ko3VRwN`n zn&^=~z^e!2*{kvB*@FlF0uLTNiElnyDu_oVW?wS%d;7k2=C?aLI{-j(wbD3%1^@~+ zhOu7kek07!+7aoJ78Q}O8gni!S}wKlniY&BVjyDRWHZ3lZVbv`LIvzY>-QG=#`d}J zNwnjvMo^XO{GC;Goghr7KasBP*s0S!N{`Z~tQ(uOVT5K_3v#CafL$$7>RK(`w3Z#a zQP7gJ)C*0=vwfc6lxz%HyYF}<+Q`wGR|x||T%Yfb1&YeH&o-79g8*p#k|p?!1?yVMr?lEzWaskPE)e@_1dNY8D-@oVxiY{0kSt!epOsr4H;S}U?TBgnDm0&$FQ#%eGcfbx^#}G6clb+x^j9~J zuU$8M&!t`&>#=dFI6o5{@L&ucqgDs=(DHeUQF8h0@1uU=MAEJFow$)j1Bw`k82Hx= zuxqh06W!1oTJMt#IU#6SlF-9p#c{(l?S@GF47 z-xwgVyphl0tmNK$WPWU~)v-Oo#)QQ+1@aW^OpRL+xfhai zliZU`4os2@AWb*RV_*zm$Re1;DVTH@hju)8KukKv29H=_jR|fG6aB?5`SuY`(c%sd z`1<`do>0%5_GZzv3r10*bVQuIy3s#S<~?`4<_wMQyTp6m;*D^Qnk%kw!8IGAC{|$N z zSZNAClxMUWeaR(+lN~F^&X6OtWK^P2lcyNT={AG$sexDMpP#_feX9}dj>~c2cru=UGwmrFPGs`uLn8bDB n(CGIb0c^-Qa;Sqgp2cTe<=7d@EYh!ZVmt&?kf=g|Ur^u;^{q(@ diff --git a/src/test/.DS_Store b/src/test/.DS_Store index 1a1a2ce96b4fa86a85777facfe2033866e3390da..850b6d07cb38b92f0b205e593a2f4aecd7eb893a 100644 GIT binary patch delta 21 ccmZoMXffDukcGp*!dOSa$k=l8Nfv8i07=~jIRF3v delta 21 ccmZoMXffDukcGp<+(bvg)X;qMNfv8i07?!9JOBUy diff --git a/src/test/java/.DS_Store b/src/test/java/.DS_Store deleted file mode 100644 index 52cb92a167feaa0bf84bda8b8022f26174b97a57..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}T>S5T4akQ;X1pg5CmNi?+2Y;w4r+cr~I2m717PgK1Wp)F7phyS|HOU&PnZ zncY?Tqc;&LJ23n0&d-MVV0SYBz?wb322ch76P3_dz~LJqKk0l z!!>QFMKhoo_}>iB*)^aIE_5ImJHPwrTYncKiuj82vgBT!^H=Xa3X`;2ePc7TMqzH= zoHtA6m2=B8Cw0?a(sa8Qv^wQH@;>LTcNPX&tGsl;#*5tj| zPeiUG9cIxiw#uvhe!a2Ns90OIok7Lw@7AjotFgH~7!=LrwT-=#)?L(z`IF?G;l(6m zQQ;>%iWpEw!z@iv zO}Z4#fM(!#7@+&XLM5~n<`Tu#frDrP5Dhd7!MXVLN3_U*Xe-Pmq6LM?R79D|RExn> z=fGq-`fU}TOO)xr#Fud&^<}0y6s8&vW{GfMwnRN@1~dbs49v=9ncn}SpZovOB)!rM zXa=T=0cIRJhfOR=y{!|)(OYYwUZavwTrN?h;GmvkF`=h;1yu<8ESezN3Ui5QLD4?~ Mf(AWk2L6 Date: Thu, 22 Dec 2022 12:21:01 +0900 Subject: [PATCH 09/10] chore: delete DS_Store --- src/main/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/main/.DS_Store diff --git a/src/main/.DS_Store b/src/main/.DS_Store deleted file mode 100644 index 850b6d07cb38b92f0b205e593a2f4aecd7eb893a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKPfyf96n_J&bV1z8E+QVZ$;QM3(G?UW99#>=5Mv;eAOvu2cZao7I&0hA6$!~6 zP4vhI@C*0>yn6QR!GoW`gGX=r=1-A7ns72k=Or`0H*emX_Whcf*8u=xH*41bOaL&j zam@5$_Y2|kyd9A)Wyv5CzQ#Ves?`GgBxX=Rk(Eh!Hb636# z5lQU%dF{BN_W3)n5%_UZDt#nf-I)_7dyF2V&scMwu(p%9Ni(+HXoZg!7z?~qcfCcQ zwku{~iiL^mhcpraevP8b>O()Qv9`^cVJ#N1j+`*EMz&%OZ*Py5ZjFstqhk|0Bi8oB zXlcZ{J~qCylQjm5S10Ey8^LDCUP;~w9!x^|6{heSmA!=gYD*ZTHty#mzOO6>T!KlMh6mumGk6KR@CM$(d-wpK;0t^sg!Ga;86+3TMN%R+ z$T+zvBfHXXb^hQpNEyd_->T(AVZg#V+EV|6?s{}g1{8fp-!c8Qn`S^W@c%Ht&j$+| z$FjnXL~(RrC$0d9{5L`f>f+ZQ(c%Wgvcir;w4e|fiYP;gx?&J@b09Jt=gZ2!BT^hBQa5@1zl(eLH~0U25n9y@Xa@c@21sVw znYJ-2Ra=kb$7`*H?J+hk+^-{1gkY!2u~2v^K8H;R&RJYREGz6tL<@@k5fC)!PBZXF G8TbJoVZkE+ From 7034574bdf1bc98153341b79862a5e69a938c06c Mon Sep 17 00:00:00 2001 From: Jihun Kim <93559865+Eithea@users.noreply.github.com> Date: Thu, 22 Dec 2022 12:21:43 +0900 Subject: [PATCH 10/10] chore: delete DS_Store --- src/test/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/test/.DS_Store diff --git a/src/test/.DS_Store b/src/test/.DS_Store deleted file mode 100644 index 850b6d07cb38b92f0b205e593a2f4aecd7eb893a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKPfyf96n_J&bV1z8E+QVZ$;QM3(G?UW99#>=5Mv;eAOvu2cZao7I&0hA6$!~6 zP4vhI@C*0>yn6QR!GoW`gGX=r=1-A7ns72k=Or`0H*emX_Whcf*8u=xH*41bOaL&j zam@5$_Y2|kyd9A)Wyv5CzQ#Ves?`GgBxX=Rk(Eh!Hb636# z5lQU%dF{BN_W3)n5%_UZDt#nf-I)_7dyF2V&scMwu(p%9Ni(+HXoZg!7z?~qcfCcQ zwku{~iiL^mhcpraevP8b>O()Qv9`^cVJ#N1j+`*EMz&%OZ*Py5ZjFstqhk|0Bi8oB zXlcZ{J~qCylQjm5S10Ey8^LDCUP;~w9!x^|6{heSmA!=gYD*ZTHty#mzOO6>T!KlMh6mumGk6KR@CM$(d-wpK;0t^sg!Ga;86+3TMN%R+ z$T+zvBfHXXb^hQpNEyd_->T(AVZg#V+EV|6?s{}g1{8fp-!c8Qn`S^W@c%Ht&j$+| z$FjnXL~(RrC$0d9{5L`f>f+ZQ(c%Wgvcir;w4e|fiYP;gx?&J@b09Jt=gZ2!BT^hBQa5@1zl(eLH~0U25n9y@Xa@c@21sVw znYJ-2Ra=kb$7`*H?J+hk+^-{1gkY!2u~2v^K8H;R&RJYREGz6tL<@@k5fC)!PBZXF G8TbJoVZkE+