From f74d90ff92a098a46c10d2f182acb5c114396876 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 15:12:09 +0900 Subject: [PATCH 01/73] =?UTF-8?q?docs:=20=EA=B8=B0=EB=8A=A5=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D/=EC=97=90=EB=9F=AC=20=EC=B2=98=EB=A6=AC=20=EC=A0=95?= =?UTF-8?q?=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/README.md b/docs/README.md index e69de29bb2d..71123d0427e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -0,0 +1,11 @@ +## 기능 목록 + +- input +1. 다리 길이를 입력 받는다. + - 3~20 사이의 숫자이다. + +## 에러 처리 +- 에러 발생시 [ERROR] 단어가 포함 되어있어야 한다. +- 그 부분 부터 다시 입력 받는다. + +1. 다리 길이는 3~20 사이의 숫자이다. \ No newline at end of file From 294a3c3e7b64c08fd6879c7cfef23f9dd898ee8a Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 15:12:53 +0900 Subject: [PATCH 02/73] =?UTF-8?q?feat:=20=EB=8B=A4=EB=A6=AC=20=EA=B8=B8?= =?UTF-8?q?=EC=9D=B4=20=EC=9E=85=EB=A0=A5=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/InputView.java | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/java/bridge/InputView.java b/src/main/java/bridge/InputView.java index c3911c8a8e7..d4f2bfe62e7 100644 --- a/src/main/java/bridge/InputView.java +++ b/src/main/java/bridge/InputView.java @@ -1,15 +1,40 @@ package bridge; - +import camp.nextstep.edu.missionutils.Console; /** * 사용자로부터 입력을 받는 역할을 한다. */ public class InputView { + private final InputValidator inputValidator; + private final OutputView outputView; + + public InputView() { + this.inputValidator = new InputValidator(); + this.outputView = new OutputView(); + } + /** * 다리의 길이를 입력받는다. */ public int readBridgeSize() { - return 0; + String input; + do { + input = inputBridgeSize(); + } while (input == null); + + return Integer.parseInt(input); + } + + private String inputBridgeSize() { + outputView.printInputBridgeSize(); + String bridgeSize = Console.readLine(); + try { + inputValidator.validateBridgeSize(bridgeSize); + } catch (IllegalArgumentException e){ + outputView.printErrorMessage(e.getMessage()); + return null; + } + return bridgeSize; } /** From 4b55d76c7ed745c262f8f82c5990a962b495963b Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 15:13:06 +0900 Subject: [PATCH 03/73] =?UTF-8?q?feat:=20=EB=8B=A4=EB=A6=AC=20=EA=B8=B8?= =?UTF-8?q?=EC=9D=B4=20=EC=9E=85=EB=A0=A5=20validator=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/InputValidator.java | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/bridge/InputValidator.java diff --git a/src/main/java/bridge/InputValidator.java b/src/main/java/bridge/InputValidator.java new file mode 100644 index 00000000000..e9f2c80005f --- /dev/null +++ b/src/main/java/bridge/InputValidator.java @@ -0,0 +1,32 @@ +package bridge; + + +public class InputValidator { + + private static final int MIN_SIZE = 3; + private static final int MAX_SIZE = 20; + private static final String NUMBER_REGEX = "^[0-9]*$"; + + public void validateBridgeSize(String bridgeSize){ + validateInputNumber(bridgeSize); + validateBridgeLength(bridgeSize); + } + + private void validateBridgeLength(String number) { + int bridgeLength = Integer.parseInt(number); + if(bridgeLength < MIN_SIZE || bridgeLength > MAX_SIZE){ + throw new IllegalArgumentException(String.format(ErrorMessage.BRIDGE_LENGTH_ERROR.getMessage(), MIN_SIZE, MAX_SIZE)); + } + } + + private void validateInputNumber(String number) { + if (!isNumeric(number)) { + throw new IllegalArgumentException(ErrorMessage.INPUT_NOT_NUMBER_ERROR.getMessage()); + } + } + + private boolean isNumeric(String str) { + return str.matches(NUMBER_REGEX); + } + +} From 02200ddd3e46088a45b9f3e8a61986450a7eb2ba Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 15:13:25 +0900 Subject: [PATCH 04/73] =?UTF-8?q?feat:=20ErrorMessage=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/ErrorMessage.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/bridge/ErrorMessage.java diff --git a/src/main/java/bridge/ErrorMessage.java b/src/main/java/bridge/ErrorMessage.java new file mode 100644 index 00000000000..8d141044928 --- /dev/null +++ b/src/main/java/bridge/ErrorMessage.java @@ -0,0 +1,19 @@ +package bridge; + +public enum ErrorMessage { + BRIDGE_LENGTH_ERROR("다리 길이는 %s~%s 사이의 숫자입니다."), + INPUT_NOT_NUMBER_ERROR("숫자가 아닙니다."); + + + private static final String error = "[ERROR] "; + private final String message; + + + ErrorMessage(String message) { + this.message = message; + } + + public String getMessage() { + return error + message; + } +} From 01b693df0a97bb013e03f65059435ca1dc2a65ba Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 15:13:50 +0900 Subject: [PATCH 05/73] =?UTF-8?q?feat:=20GameProgressMessage=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/GameProgressMessage.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/bridge/GameProgressMessage.java diff --git a/src/main/java/bridge/GameProgressMessage.java b/src/main/java/bridge/GameProgressMessage.java new file mode 100644 index 00000000000..06521f663c1 --- /dev/null +++ b/src/main/java/bridge/GameProgressMessage.java @@ -0,0 +1,17 @@ +package bridge; + +public enum GameProgressMessage { + + INPUT_BRIDGE_LENGTH("다리의 길이를 입력해주세요."); + + private final String message; + + GameProgressMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + return message; + } +} From 6705e566e5eec6a9ed870a9fe58de14aafcfd108 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 15:15:25 +0900 Subject: [PATCH 06/73] =?UTF-8?q?feat:=20outputView=20printInputBridgeSize?= =?UTF-8?q?=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/OutputView.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/bridge/OutputView.java b/src/main/java/bridge/OutputView.java index 69a433a6285..068cf84ab9e 100644 --- a/src/main/java/bridge/OutputView.java +++ b/src/main/java/bridge/OutputView.java @@ -20,4 +20,12 @@ public void printMap() { */ public void printResult() { } + + public void printErrorMessage(String errorMessage){ + System.out.println(errorMessage); + } + + public void printInputBridgeSize() { + System.out.println(GameProgressMessage.INPUT_BRIDGE_LENGTH); + } } From 5cc0f3c060550ebf240d2a029b8067c5f897f2b0 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 15:16:42 +0900 Subject: [PATCH 07/73] =?UTF-8?q?test:=20=EB=8B=A4=EB=A6=AC=20=EA=B8=B8?= =?UTF-8?q?=EC=9D=B4=20InputValidator=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/InputValidatorTest.java | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/test/java/bridge/InputValidatorTest.java diff --git a/src/test/java/bridge/InputValidatorTest.java b/src/test/java/bridge/InputValidatorTest.java new file mode 100644 index 00000000000..62ae5be7a9f --- /dev/null +++ b/src/test/java/bridge/InputValidatorTest.java @@ -0,0 +1,25 @@ +package bridge; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.*; + +class InputValidatorTest { + + InputValidator inputValidator = new InputValidator(); + + @Test + @DisplayName("다리 길이가 3~20사이가 아니면 에러가 발생한다.") + void validateBridgeLength(){ + assertThatThrownBy(() -> inputValidator.validateBridgeSize("21")) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + @DisplayName("다리 길이가 숫자가 아니면 에러가 발생한다.") + void validateBridgeIsNumber(){ + assertThatThrownBy(() -> inputValidator.validateBridgeSize("ㅁ")) + .isInstanceOf(IllegalArgumentException.class); + } + +} From 2d49a41ed08f0c9df0bcd9d5ba152ccffe0eb7fa Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 16:04:53 +0900 Subject: [PATCH 08/73] =?UTF-8?q?docs:=20=EB=8B=A4=EB=A6=AC=20=EA=B8=B8?= =?UTF-8?q?=EC=9D=B4=20=EB=A7=8C=ED=81=BC=20=EB=8B=A4=EB=A6=AC=EB=A5=BC=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/README.md b/docs/README.md index 71123d0427e..43467aae562 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,6 +4,11 @@ 1. 다리 길이를 입력 받는다. - 3~20 사이의 숫자이다. +- bridge +1. 다리 길이 만큼 다리를 생성한다. + - List 위 칸 -> U, 아래 칸 -> D + - 랜덤 숫자 1 -> 위 칸, 0 -> 아래 칸 + ## 에러 처리 - 에러 발생시 [ERROR] 단어가 포함 되어있어야 한다. - 그 부분 부터 다시 입력 받는다. From 27eff97393619fe37221863bb60d9c659f91a73a Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 16:05:26 +0900 Subject: [PATCH 09/73] =?UTF-8?q?feat:=20GameCommand=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/GameCommand.java | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/bridge/GameCommand.java diff --git a/src/main/java/bridge/GameCommand.java b/src/main/java/bridge/GameCommand.java new file mode 100644 index 00000000000..2726f534ec0 --- /dev/null +++ b/src/main/java/bridge/GameCommand.java @@ -0,0 +1,30 @@ +package bridge; + +public enum GameCommand { + UP_STAIR("U"), + DOWN_STAIR("D"); + + + private final static int DOWN_RANDOM_NUMBER = 0; + private final String command; + + GameCommand(String command) { + this.command = command; + } + + public String getCommand() { + return command; + } + + @Override + public String toString() { + return command; + } + + public static String bridgeStageCase(int num){ + if (num == DOWN_RANDOM_NUMBER){ + return DOWN_STAIR.getCommand(); + } + return UP_STAIR.getCommand(); + } +} From 6faa1cd2e07d7023b3279a7f7f00b80499dbe844 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 16:05:44 +0900 Subject: [PATCH 10/73] =?UTF-8?q?feat:=20makeBridge=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/BridgeMaker.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/bridge/BridgeMaker.java b/src/main/java/bridge/BridgeMaker.java index 27e9f2cfa7f..6e7dc6779d9 100644 --- a/src/main/java/bridge/BridgeMaker.java +++ b/src/main/java/bridge/BridgeMaker.java @@ -1,6 +1,8 @@ package bridge; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; /** * 다리의 길이를 입력 받아서 다리를 생성해주는 역할을 한다. @@ -18,6 +20,9 @@ public BridgeMaker(BridgeNumberGenerator bridgeNumberGenerator) { * @return 입력받은 길이에 해당하는 다리 모양. 위 칸이면 "U", 아래 칸이면 "D"로 표현해야 한다. */ public List makeBridge(int size) { - return null; + return IntStream.range(0, size) + .mapToObj(i -> bridgeNumberGenerator.generate()) + .map(GameCommand::bridgeStageCase) + .collect(Collectors.toList()); } } From 6fa6061440270802dbc326e150f3c483812caa2a Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 16:06:10 +0900 Subject: [PATCH 11/73] =?UTF-8?q?test:=20=EB=8B=A4=EB=A6=AC=EA=B0=80=20'U'?= =?UTF-8?q?,'D'=EB=A1=9C=20=EA=B5=AC=EC=84=B1=EB=90=98=EC=96=B4=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/BridgeGameTest.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/java/bridge/BridgeGameTest.java diff --git a/src/test/java/bridge/BridgeGameTest.java b/src/test/java/bridge/BridgeGameTest.java new file mode 100644 index 00000000000..021dee363c5 --- /dev/null +++ b/src/test/java/bridge/BridgeGameTest.java @@ -0,0 +1,24 @@ +package bridge; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.util.List; +import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.util.Lists.newArrayList; + +class BridgeGameTest { + + BridgeNumberGenerator numberGenerator = new ApplicationTest.TestNumberGenerator(newArrayList(1, 0, 0)); + BridgeMaker bridgeMaker = new BridgeMaker(numberGenerator); + List bridge = bridgeMaker.makeBridge(3); + + + @Test + @DisplayName("다리가 'U','D'로 구성되어 있는지 확인한다.") + void BridgeComposeByUAndD(){ + assertThat(bridge).containsExactly("U", "D", "D"); + } + + +} From 6cc2dac98029b1eb6ac5fa81a79b74cc91ba338d Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 16:06:55 +0900 Subject: [PATCH 12/73] =?UTF-8?q?test:=20=EC=9E=85=EB=A0=A5=EB=90=9C=20?= =?UTF-8?q?=EA=B8=B8=EC=9D=B4=20=EB=A7=8C=ED=81=BC=20=EB=8B=A4=EB=A6=AC?= =?UTF-8?q?=EA=B0=80=20=ED=81=AC=EA=B8=B0=EA=B0=80=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9D=B4=20=EB=90=9C=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/BridgeGameTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/java/bridge/BridgeGameTest.java b/src/test/java/bridge/BridgeGameTest.java index 021dee363c5..32987fdca2f 100644 --- a/src/test/java/bridge/BridgeGameTest.java +++ b/src/test/java/bridge/BridgeGameTest.java @@ -20,5 +20,9 @@ void BridgeComposeByUAndD(){ assertThat(bridge).containsExactly("U", "D", "D"); } - + @Test + @DisplayName("입력된 길이 만큼 다리가 크기가 생성이 된는지 확인한다.") + void makeBridgeSize(){ + assertThat(bridge.size()).isEqualTo(3); + } } From 209d74d6e0725e1fdd523cb605f87b19e2c44f6f Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 17:21:48 +0900 Subject: [PATCH 13/73] =?UTF-8?q?docs:=20=EC=9D=B4=EB=8F=99=ED=95=A0=20?= =?UTF-8?q?=EC=B9=B8=EC=9D=84=20=EC=9E=85=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 43467aae562..9f17f6ba052 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3,6 +3,12 @@ - input 1. 다리 길이를 입력 받는다. - 3~20 사이의 숫자이다. +2. 이동할 칸을 입력 받는다. + - 위 칸 -> U, 아래 칸 -> D + +- output +1. 다리 화면 출력 + - 이동한 칸을 건널 수 있다면 -> O 건널 수 없다면 X - bridge 1. 다리 길이 만큼 다리를 생성한다. @@ -13,4 +19,5 @@ - 에러 발생시 [ERROR] 단어가 포함 되어있어야 한다. - 그 부분 부터 다시 입력 받는다. -1. 다리 길이는 3~20 사이의 숫자이다. \ No newline at end of file +1. 다리 길이는 3~20 사이의 숫자이다. +2. 이동할 칸은 'U', 'D' 이다. \ No newline at end of file From 55de42f750c005c8ae8dcd29171122a5c1b6aeeb Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 17:22:32 +0900 Subject: [PATCH 14/73] =?UTF-8?q?feat:=20=EC=9D=B4=EB=8F=99=ED=95=A0=20?= =?UTF-8?q?=EC=B9=B8=20ErrorMessage=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/ErrorMessage.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/bridge/ErrorMessage.java b/src/main/java/bridge/ErrorMessage.java index 8d141044928..f35a6c3dd83 100644 --- a/src/main/java/bridge/ErrorMessage.java +++ b/src/main/java/bridge/ErrorMessage.java @@ -1,8 +1,14 @@ package bridge; public enum ErrorMessage { + + // bridge BRIDGE_LENGTH_ERROR("다리 길이는 %s~%s 사이의 숫자입니다."), - INPUT_NOT_NUMBER_ERROR("숫자가 아닙니다."); + BRIDGE_STAGE_COMMAND_ERROR("이동할 칸은 %s 혹은 %s 입니다."), + + // global + INPUT_NOT_NUMBER_ERROR("숫자가 아닙니다."), + INPUT_NOT_UPPER_ENGLISH_ERROR("대문자 영어가 아닙니다."); private static final String error = "[ERROR] "; From 5b0e88d4fb432eb2e8373b6e9b1e4e4670e1f519 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 17:23:16 +0900 Subject: [PATCH 15/73] =?UTF-8?q?feat:=20GameCommand=EC=97=90=20isNotBridg?= =?UTF-8?q?eStageCommand=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/GameCommand.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/bridge/GameCommand.java b/src/main/java/bridge/GameCommand.java index 2726f534ec0..cf6975cd40a 100644 --- a/src/main/java/bridge/GameCommand.java +++ b/src/main/java/bridge/GameCommand.java @@ -27,4 +27,8 @@ public static String bridgeStageCase(int num){ } return UP_STAIR.getCommand(); } + + public static boolean isNotBridgeStageCommand(String bridgeStage) { + return !bridgeStage.equals(UP_STAIR.getCommand()) && !bridgeStage.equals(DOWN_STAIR.getCommand()); + } } From 896cd7120e4d14a1731d72632e05f9c6cd3a54cd Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 17:23:40 +0900 Subject: [PATCH 16/73] =?UTF-8?q?feat:=20GameProgressMessage=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99=ED=95=A0=20=EC=B9=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/GameProgressMessage.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/bridge/GameProgressMessage.java b/src/main/java/bridge/GameProgressMessage.java index 06521f663c1..f9512802c55 100644 --- a/src/main/java/bridge/GameProgressMessage.java +++ b/src/main/java/bridge/GameProgressMessage.java @@ -2,8 +2,9 @@ public enum GameProgressMessage { - INPUT_BRIDGE_LENGTH("다리의 길이를 입력해주세요."); - + INPUT_BRIDGE_LENGTH("다리의 길이를 입력해주세요."), + INPUT_BRIDGE_STAGE("이동할 칸을 선택해주세요. (위: %s, 아래: %s)"); + private final String message; GameProgressMessage(String message) { From bfd6f34cd857a0d35e51de313a3fdf9e6289a9a1 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 17:24:24 +0900 Subject: [PATCH 17/73] =?UTF-8?q?feat:=20InputValidator=20validateBridgeSt?= =?UTF-8?q?age=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/InputValidator.java | 40 ++++++++++++++++++++---- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/main/java/bridge/InputValidator.java b/src/main/java/bridge/InputValidator.java index e9f2c80005f..959b2742de4 100644 --- a/src/main/java/bridge/InputValidator.java +++ b/src/main/java/bridge/InputValidator.java @@ -6,27 +6,55 @@ public class InputValidator { private static final int MIN_SIZE = 3; private static final int MAX_SIZE = 20; private static final String NUMBER_REGEX = "^[0-9]*$"; + private static final String UPPER_ENGLISH_REGEX ="^[A-Z]*$"; public void validateBridgeSize(String bridgeSize){ validateInputNumber(bridgeSize); validateBridgeLength(bridgeSize); } + private void validateInputNumber(String number) { + if (isNotNumeric(number)) { + throw new IllegalArgumentException(ErrorMessage.INPUT_NOT_NUMBER_ERROR.getMessage()); + } + } + + private boolean isNotNumeric(String str) { + return !str.matches(NUMBER_REGEX); + } + private void validateBridgeLength(String number) { int bridgeLength = Integer.parseInt(number); - if(bridgeLength < MIN_SIZE || bridgeLength > MAX_SIZE){ + if(isNotBridgeLength(bridgeLength)){ throw new IllegalArgumentException(String.format(ErrorMessage.BRIDGE_LENGTH_ERROR.getMessage(), MIN_SIZE, MAX_SIZE)); } } - private void validateInputNumber(String number) { - if (!isNumeric(number)) { - throw new IllegalArgumentException(ErrorMessage.INPUT_NOT_NUMBER_ERROR.getMessage()); + private boolean isNotBridgeLength(int bridgeLength){ + return bridgeLength < MIN_SIZE || bridgeLength > MAX_SIZE; + } + + public void validateBridgeStage(String bridgeStage) { + validateInputUpperEnglish(bridgeStage); + validateBridgeStageCommand(bridgeStage); + } + + private void validateInputUpperEnglish(String bridgeStage) { + if (isNotUpperEnglish(bridgeStage)){ + throw new IllegalArgumentException(ErrorMessage.INPUT_NOT_UPPER_ENGLISH_ERROR.getMessage()); } } - private boolean isNumeric(String str) { - return str.matches(NUMBER_REGEX); + private boolean isNotUpperEnglish(String str){ + return !str.matches(UPPER_ENGLISH_REGEX); } + private void validateBridgeStageCommand(String bridgeStage) { + if(GameCommand.isNotBridgeStageCommand(bridgeStage)){ + throw new IllegalArgumentException(String.format(ErrorMessage.BRIDGE_STAGE_COMMAND_ERROR.getMessage() + , GameCommand.UP_STAIR, GameCommand.DOWN_STAIR)); + } + } + + } From 7a00d9d42ac889ff4f0ff8eb5500a0706a50e515 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 17:24:49 +0900 Subject: [PATCH 18/73] =?UTF-8?q?feat:=20InputView=20=EC=9D=B4=EB=8F=99?= =?UTF-8?q?=ED=95=A0=20=EC=B9=B8=20=EC=9E=85=EB=A0=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/InputView.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/bridge/InputView.java b/src/main/java/bridge/InputView.java index d4f2bfe62e7..93d1f3e3b12 100644 --- a/src/main/java/bridge/InputView.java +++ b/src/main/java/bridge/InputView.java @@ -41,7 +41,24 @@ private String inputBridgeSize() { * 사용자가 이동할 칸을 입력받는다. */ public String readMoving() { - return null; + String input; + do { + input = inputBridgeStage(); + }while (input == null); + + return input; + } + + private String inputBridgeStage() { + outputView.printInputBridgeStage(); + String bridgeStage = Console.readLine(); + try { + inputValidator.validateBridgeStage(bridgeStage); + }catch (IllegalArgumentException e){ + outputView.printErrorMessage(e.getMessage()); + return null; + } + return bridgeStage; } /** From 651e5188ed19d726707057f2b1be0ad8416532ac Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 17:25:21 +0900 Subject: [PATCH 19/73] =?UTF-8?q?feat:=20OutputView=20printInputBridgeStag?= =?UTF-8?q?e=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/OutputView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/bridge/OutputView.java b/src/main/java/bridge/OutputView.java index 068cf84ab9e..166e82987b8 100644 --- a/src/main/java/bridge/OutputView.java +++ b/src/main/java/bridge/OutputView.java @@ -28,4 +28,10 @@ public void printErrorMessage(String errorMessage){ public void printInputBridgeSize() { System.out.println(GameProgressMessage.INPUT_BRIDGE_LENGTH); } + + public void printInputBridgeStage(){ + String message = String.format(GameProgressMessage.INPUT_BRIDGE_STAGE.toString() + , GameCommand.UP_STAIR, GameCommand.DOWN_STAIR); + System.out.println(message); + } } From 6c01772b0757eac8ea1f12c0526b9cdeb93b2a60 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 17:25:42 +0900 Subject: [PATCH 20/73] =?UTF-8?q?feat:=20InputValidatorTest=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99=ED=95=A0=20=EC=B9=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/InputValidatorTest.java | 23 +++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/test/java/bridge/InputValidatorTest.java b/src/test/java/bridge/InputValidatorTest.java index 62ae5be7a9f..3d57e4d2e26 100644 --- a/src/test/java/bridge/InputValidatorTest.java +++ b/src/test/java/bridge/InputValidatorTest.java @@ -8,6 +8,13 @@ class InputValidatorTest { InputValidator inputValidator = new InputValidator(); + @Test + @DisplayName("다리 길이가 숫자가 아니면 에러가 발생한다.") + void validateBridgeIsNumber(){ + assertThatThrownBy(() -> inputValidator.validateBridgeSize("ㅁ")) + .isInstanceOf(IllegalArgumentException.class); + } + @Test @DisplayName("다리 길이가 3~20사이가 아니면 에러가 발생한다.") void validateBridgeLength(){ @@ -16,10 +23,20 @@ void validateBridgeLength(){ } @Test - @DisplayName("다리 길이가 숫자가 아니면 에러가 발생한다.") - void validateBridgeIsNumber(){ - assertThatThrownBy(() -> inputValidator.validateBridgeSize("ㅁ")) + @DisplayName("이동할 칸은 대문자 영어가 아니면 에러가 발생한다.") + void validateBridgeStageUpperEnglish(){ + assertThatThrownBy(() -> inputValidator.validateBridgeStage("u")) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + @DisplayName("이동할 칸은 'U' 혹은 'D'가 아니면 에러가 발생한다.") + void validateBridgeStage(){ + assertThatThrownBy(() -> inputValidator.validateBridgeStage("T")) .isInstanceOf(IllegalArgumentException.class); } + + + } From 871c1d9e5e564551268ff0ab9c82ceef5821edfe Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 22:22:39 +0900 Subject: [PATCH 21/73] =?UTF-8?q?docs:=20Bridge=20=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/README.md b/docs/README.md index 9f17f6ba052..bd93077166f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -14,6 +14,8 @@ 1. 다리 길이 만큼 다리를 생성한다. - List 위 칸 -> U, 아래 칸 -> D - 랜덤 숫자 1 -> 위 칸, 0 -> 아래 칸 +2. 이동 했을 때 성공/실패를 비교한다. +3. 다리의 상태에 대한 화면을 생성한다. ## 에러 처리 - 에러 발생시 [ERROR] 단어가 포함 되어있어야 한다. From 3903ace3854d040d4405d21f9216c8ae4de89eac Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 22:23:04 +0900 Subject: [PATCH 22/73] =?UTF-8?q?feat:=20BridgeGame=20move=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/BridgeGame.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/bridge/BridgeGame.java b/src/main/java/bridge/BridgeGame.java index 834c1c8362b..c984e15eaa2 100644 --- a/src/main/java/bridge/BridgeGame.java +++ b/src/main/java/bridge/BridgeGame.java @@ -5,12 +5,31 @@ */ public class BridgeGame { + private final BridgeMaker bridgeMaker; + private final BridgeWindowMaker bridgeWindowMaker; + private Bridge bridge; + + public BridgeGame() { + this.bridgeMaker = new BridgeMaker(new BridgeRandomNumberGenerator()); + this.bridgeWindowMaker = new BridgeWindowMaker(); + } + + public void makeBridge(int bridge){ + this.bridge = new Bridge(bridgeMaker.makeBridge(bridge)); + } + + /** * 사용자가 칸을 이동할 때 사용하는 메서드 *

* 이동을 위해 필요한 메서드의 반환 타입(return type), 인자(parameter)는 자유롭게 추가하거나 변경할 수 있다. */ - public void move() { + public Bridge move(String bridgeStageCommand) { + int curStage = BridgeStageRecord.getCurStage(); + boolean stageStatus = bridge.isStageStatus(bridgeStageCommand, curStage); + bridgeWindowMaker.moveStair(bridgeStageCommand, stageStatus); + BridgeStageRecord.nextStage(); + return bridge; } /** From 466550198a916702cf890c66d52a186f3706729d Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 22:23:18 +0900 Subject: [PATCH 23/73] =?UTF-8?q?feat:=20Bridge=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/Bridge.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/bridge/Bridge.java diff --git a/src/main/java/bridge/Bridge.java b/src/main/java/bridge/Bridge.java new file mode 100644 index 00000000000..9700c05aa90 --- /dev/null +++ b/src/main/java/bridge/Bridge.java @@ -0,0 +1,29 @@ +package bridge; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class Bridge { + private static final int DEFAULT_STAGE_NUM = 1; + private final List bridge; + public Bridge(List bridge) { + this.bridge = new ArrayList<>(bridge); + } + + public List getBridge() { + return Collections.unmodifiableList(bridge); + } + + public int stages(){ + return bridge.size(); + } + + public boolean isStageStatus(String bridgeStage, int curStage){ + return bridge.get(curStage).equals(bridgeStage); + } + + public boolean clearGame(int curStage) { + return stages() == curStage+DEFAULT_STAGE_NUM; + } +} From 84fcafc1f0439f9a6c4159176006bc7aa4b90ca2 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 22:24:35 +0900 Subject: [PATCH 24/73] =?UTF-8?q?feat:=20BridgeStageRecord=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/BridgeStageRecord.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/bridge/BridgeStageRecord.java diff --git a/src/main/java/bridge/BridgeStageRecord.java b/src/main/java/bridge/BridgeStageRecord.java new file mode 100644 index 00000000000..1813347aa41 --- /dev/null +++ b/src/main/java/bridge/BridgeStageRecord.java @@ -0,0 +1,20 @@ +package bridge; + +public class BridgeStageRecord { + + private static final int firstStage = 0; + private static int curStage = firstStage; + + public static int getCurStage() { + return curStage; + } + + public static void nextStage(){ + curStage++; + } + + public static void reset(){ + curStage = firstStage; + } + +} From 351ee56e3b9be0b2a541227a7db3a89b659803da Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 22:25:42 +0900 Subject: [PATCH 25/73] =?UTF-8?q?feat:=20BridgeWindowElement=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/BridgeWindowElement.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/bridge/BridgeWindowElement.java diff --git a/src/main/java/bridge/BridgeWindowElement.java b/src/main/java/bridge/BridgeWindowElement.java new file mode 100644 index 00000000000..4882bd8801e --- /dev/null +++ b/src/main/java/bridge/BridgeWindowElement.java @@ -0,0 +1,29 @@ +package bridge; + +public enum BridgeWindowElement { + START("[ "), + SUCCESS("O"), + FAIL("X"), + DIVISION(" | "), + BLANK(" "), + END(" ]"); + + private final String value; + + BridgeWindowElement(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } + + public static BridgeWindowElement getStageWindowElement(boolean stageStatus) { + if (stageStatus){ + return SUCCESS; + } + return FAIL; + } + +} From ce51a482c31989da96cedfcc3274340217486848 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 22:26:01 +0900 Subject: [PATCH 26/73] =?UTF-8?q?feat:=20BridgeWindowMaker=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/BridgeWindowMaker.java | 65 +++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/main/java/bridge/BridgeWindowMaker.java diff --git a/src/main/java/bridge/BridgeWindowMaker.java b/src/main/java/bridge/BridgeWindowMaker.java new file mode 100644 index 00000000000..be647fcd9ea --- /dev/null +++ b/src/main/java/bridge/BridgeWindowMaker.java @@ -0,0 +1,65 @@ +package bridge; + +import java.util.ArrayList; +import java.util.List; + +public class BridgeWindowMaker { + + private static final int INIT_SIZE = 2; + private static final int LENGTH_ONE = 1; + + private final List upStair = new ArrayList<>(); + private final List downStair = new ArrayList<>(); + + public BridgeWindowMaker(){ + init(); + } + + private void init(){ + upStair.add(BridgeWindowElement.START); + upStair.add(BridgeWindowElement.END); + downStair.add(BridgeWindowElement.START); + downStair.add(BridgeWindowElement.END); + } + + public void reset() { + upStair.clear(); + downStair.clear(); + init(); + } + public void moveStair(String bridgeStair, boolean stageStatus) { + inputDivision(); + BridgeWindowElement windowElement = BridgeWindowElement.getStageWindowElement(stageStatus); + + if (GameCommand.isBridgeStageCommandU(bridgeStair)) { + upStair.add(getInsertMiddle(upStair), windowElement); + downStair.add(getInsertMiddle(downStair), BridgeWindowElement.BLANK); + return; + } + upStair.add(getInsertMiddle(upStair), BridgeWindowElement.BLANK); + downStair.add(getInsertMiddle(downStair), windowElement); + } + + + private void inputDivision(){ + if (upStair.size() == INIT_SIZE){ + return; + } + upStair.add(getInsertMiddle(upStair), BridgeWindowElement.DIVISION); + downStair.add(getInsertMiddle(downStair), BridgeWindowElement.DIVISION); + } + + private int getInsertMiddle(List stair){ + return stair.size() - LENGTH_ONE; + } + + @Override + public String toString() { + StringBuilder stringBuilder = new StringBuilder(); + upStair.forEach(stringBuilder::append); + stringBuilder.append("\n"); + downStair.forEach(stringBuilder::append); + stringBuilder.append("\n"); + return stringBuilder.toString(); + } +} From 25120fcbd9b29feee78bceac5ea6a6031d6bc0cf Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 22:26:27 +0900 Subject: [PATCH 27/73] =?UTF-8?q?feat:=20GameCommand=20isBridgeStageComman?= =?UTF-8?q?dU=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/GameCommand.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/bridge/GameCommand.java b/src/main/java/bridge/GameCommand.java index cf6975cd40a..f8fdb78e22e 100644 --- a/src/main/java/bridge/GameCommand.java +++ b/src/main/java/bridge/GameCommand.java @@ -31,4 +31,8 @@ public static String bridgeStageCase(int num){ public static boolean isNotBridgeStageCommand(String bridgeStage) { return !bridgeStage.equals(UP_STAIR.getCommand()) && !bridgeStage.equals(DOWN_STAIR.getCommand()); } + + public static boolean isBridgeStageCommandU(String bridgeStage){ + return bridgeStage.equals(UP_STAIR.getCommand()); + } } From e263391fe813352e33657b4542b9ff64a22c29fb Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 22:27:00 +0900 Subject: [PATCH 28/73] =?UTF-8?q?test:=20=EC=83=9D=EC=84=B1=EB=90=9C=20?= =?UTF-8?q?=EB=8B=A4=EB=A6=AC=EA=B0=80=20Bridge=EC=97=90=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=EC=9D=B4=20=EB=90=98=EB=8A=94=EC=A7=80=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...{BridgeGameTest.java => BridgeMakerTest.java} | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) rename src/test/java/bridge/{BridgeGameTest.java => BridgeMakerTest.java} (70%) diff --git a/src/test/java/bridge/BridgeGameTest.java b/src/test/java/bridge/BridgeMakerTest.java similarity index 70% rename from src/test/java/bridge/BridgeGameTest.java rename to src/test/java/bridge/BridgeMakerTest.java index 32987fdca2f..72cd477c658 100644 --- a/src/test/java/bridge/BridgeGameTest.java +++ b/src/test/java/bridge/BridgeMakerTest.java @@ -7,7 +7,7 @@ import static org.assertj.core.api.Assertions.*; import static org.assertj.core.util.Lists.newArrayList; -class BridgeGameTest { +class BridgeMakerTest { BridgeNumberGenerator numberGenerator = new ApplicationTest.TestNumberGenerator(newArrayList(1, 0, 0)); BridgeMaker bridgeMaker = new BridgeMaker(numberGenerator); @@ -25,4 +25,18 @@ void BridgeComposeByUAndD(){ void makeBridgeSize(){ assertThat(bridge.size()).isEqualTo(3); } + + @Test + @DisplayName("생성된 다리가 Bridge에 저장이 되는지 확인한다.") + void saveBridge(){ + //given + Bridge saveBridge = new Bridge(bridge); + + //when + List savedBridge = saveBridge.getBridge(); + + //then + assertThat(savedBridge).isEqualTo(bridge); + } + } From ad49f8500cd89bac274f09c667c76bfd7ee179d8 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 22:27:36 +0900 Subject: [PATCH 29/73] =?UTF-8?q?test:=20bridge=EC=97=90=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=ED=95=A0=20=EC=B9=B8=EC=9D=B4=20=EB=A7=9E=EC=9C=BC?= =?UTF-8?q?=EB=A9=B4=20true=EB=A5=BC=20=EB=B0=98=ED=99=98=ED=95=98?= =?UTF-8?q?=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/BridgeMakerTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/bridge/BridgeMakerTest.java b/src/test/java/bridge/BridgeMakerTest.java index 72cd477c658..c3621eda344 100644 --- a/src/test/java/bridge/BridgeMakerTest.java +++ b/src/test/java/bridge/BridgeMakerTest.java @@ -39,4 +39,16 @@ void saveBridge(){ assertThat(savedBridge).isEqualTo(bridge); } + @Test + @DisplayName("bridge에 입력할 칸이 맞으면 true를 반환하는지 확인한다.") + void checkBridgeStage(){ + //given + Bridge saveBridge = new Bridge(bridge); + + //when + boolean stageStatus = saveBridge.isStageStatus("U", 0); + + //then + assertThat(stageStatus).isTrue(); + } } From 37f0ef8e91cd5ebdd24c16cba81948b8f834e626 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Wed, 23 Aug 2023 22:27:49 +0900 Subject: [PATCH 30/73] =?UTF-8?q?test:=20=EC=9E=85=EB=A0=A5=ED=95=9C=20?= =?UTF-8?q?=EC=B9=B8=EC=9D=B4=20=EC=84=B1=EA=B3=B5=ED=96=88=EC=9D=84=20?= =?UTF-8?q?=EB=95=8C=20SUCCESS=EB=A5=BC=20=EB=B0=98=ED=99=98=ED=95=98?= =?UTF-8?q?=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/BridgeWindowTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/test/java/bridge/BridgeWindowTest.java diff --git a/src/test/java/bridge/BridgeWindowTest.java b/src/test/java/bridge/BridgeWindowTest.java new file mode 100644 index 00000000000..56fd6d8737c --- /dev/null +++ b/src/test/java/bridge/BridgeWindowTest.java @@ -0,0 +1,15 @@ +package bridge; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.*; +class BridgeWindowTest { + + @Test + @DisplayName("입력한 칸이 성공했을 때 SUCCESS를 반환하는지 확인한다.") + void getBridgeWindowElement(){ + BridgeWindowElement bridgeWindowElement = BridgeWindowElement.getStageWindowElement(true); + assertThat(bridgeWindowElement).isEqualTo(BridgeWindowElement.SUCCESS); + } + +} From 278375987602328e9b256b07dc007ed2e240f041 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Thu, 24 Aug 2023 01:22:38 +0900 Subject: [PATCH 31/73] =?UTF-8?q?refactor:=20Bridge=20boolean=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/Bridge.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/bridge/Bridge.java b/src/main/java/bridge/Bridge.java index 9700c05aa90..df2a1d2b1ee 100644 --- a/src/main/java/bridge/Bridge.java +++ b/src/main/java/bridge/Bridge.java @@ -19,11 +19,11 @@ public int stages(){ return bridge.size(); } - public boolean isStageStatus(String bridgeStage, int curStage){ + public boolean canMoveStage(String bridgeStage, int curStage){ return bridge.get(curStage).equals(bridgeStage); } - public boolean clearGame(int curStage) { - return stages() == curStage+DEFAULT_STAGE_NUM; + public boolean clearsAllStage(int curStage) { + return stages() > curStage+DEFAULT_STAGE_NUM; } } From 31da5aeca6fad0ab7949572b3fba53933f13c799 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Thu, 24 Aug 2023 01:23:13 +0900 Subject: [PATCH 32/73] =?UTF-8?q?refactor:=20BridgeGame=20move=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/BridgeGame.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/bridge/BridgeGame.java b/src/main/java/bridge/BridgeGame.java index c984e15eaa2..0b244ad1271 100644 --- a/src/main/java/bridge/BridgeGame.java +++ b/src/main/java/bridge/BridgeGame.java @@ -5,6 +5,7 @@ */ public class BridgeGame { + private static final boolean CLEARS_GAME = true; private final BridgeMaker bridgeMaker; private final BridgeWindowMaker bridgeWindowMaker; private Bridge bridge; @@ -24,12 +25,12 @@ public void makeBridge(int bridge){ *

* 이동을 위해 필요한 메서드의 반환 타입(return type), 인자(parameter)는 자유롭게 추가하거나 변경할 수 있다. */ - public Bridge move(String bridgeStageCommand) { + public void move(String bridgeStageCommand) { int curStage = BridgeStageRecord.getCurStage(); - boolean stageStatus = bridge.isStageStatus(bridgeStageCommand, curStage); - bridgeWindowMaker.moveStair(bridgeStageCommand, stageStatus); + boolean canMoveStage = bridge.canMoveStage(bridgeStageCommand, curStage); + bridgeWindowMaker.moveStair(bridgeStageCommand, canMoveStage); + checksStageStatus(canMoveStage); BridgeStageRecord.nextStage(); - return bridge; } /** @@ -39,4 +40,15 @@ public Bridge move(String bridgeStageCommand) { */ public void retry() { } + + public void checksStageStatus(boolean canMoveStage){ + if (bridge.clearsAllStage(BridgeStageRecord.getCurStage())) { + BridgeStageRecord.changeProgressStatus(CLEARS_GAME); + } + BridgeStageRecord.changeMoveStatus(canMoveStage); + } + + public BridgeWindowMaker getBridgeWindowMaker() { + return bridgeWindowMaker; + } } From 92aeff8b14d7059d197fe2b896c9e20298b365d3 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Thu, 24 Aug 2023 01:23:54 +0900 Subject: [PATCH 33/73] =?UTF-8?q?refactor:=20=EB=B3=80=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/BridgeWindowElement.java | 4 ++-- src/main/java/bridge/BridgeWindowMaker.java | 4 ++-- src/test/java/bridge/BridgeMakerTest.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/bridge/BridgeWindowElement.java b/src/main/java/bridge/BridgeWindowElement.java index 4882bd8801e..42fa7d3290c 100644 --- a/src/main/java/bridge/BridgeWindowElement.java +++ b/src/main/java/bridge/BridgeWindowElement.java @@ -19,8 +19,8 @@ public String toString() { return value; } - public static BridgeWindowElement getStageWindowElement(boolean stageStatus) { - if (stageStatus){ + public static BridgeWindowElement getStageWindowElement(boolean canMoveStage) { + if (canMoveStage){ return SUCCESS; } return FAIL; diff --git a/src/main/java/bridge/BridgeWindowMaker.java b/src/main/java/bridge/BridgeWindowMaker.java index be647fcd9ea..0b32a170702 100644 --- a/src/main/java/bridge/BridgeWindowMaker.java +++ b/src/main/java/bridge/BridgeWindowMaker.java @@ -27,9 +27,9 @@ public void reset() { downStair.clear(); init(); } - public void moveStair(String bridgeStair, boolean stageStatus) { + public void moveStair(String bridgeStair, boolean canMoveStage) { inputDivision(); - BridgeWindowElement windowElement = BridgeWindowElement.getStageWindowElement(stageStatus); + BridgeWindowElement windowElement = BridgeWindowElement.getStageWindowElement(canMoveStage); if (GameCommand.isBridgeStageCommandU(bridgeStair)) { upStair.add(getInsertMiddle(upStair), windowElement); diff --git a/src/test/java/bridge/BridgeMakerTest.java b/src/test/java/bridge/BridgeMakerTest.java index c3621eda344..7cda06773e0 100644 --- a/src/test/java/bridge/BridgeMakerTest.java +++ b/src/test/java/bridge/BridgeMakerTest.java @@ -46,7 +46,7 @@ void checkBridgeStage(){ Bridge saveBridge = new Bridge(bridge); //when - boolean stageStatus = saveBridge.isStageStatus("U", 0); + boolean stageStatus = saveBridge.canMoveStage("U", 0); //then assertThat(stageStatus).isTrue(); From 0554e3ba60a45fa26ad6164c3e51ee0ec4dd9a03 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Thu, 24 Aug 2023 01:24:27 +0900 Subject: [PATCH 34/73] =?UTF-8?q?refactor:=20BRIDGE=5FGAME=5FSTART=20?= =?UTF-8?q?=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/GameProgressMessage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/bridge/GameProgressMessage.java b/src/main/java/bridge/GameProgressMessage.java index f9512802c55..89125a4b17a 100644 --- a/src/main/java/bridge/GameProgressMessage.java +++ b/src/main/java/bridge/GameProgressMessage.java @@ -2,6 +2,7 @@ public enum GameProgressMessage { + BRIDGE_GAME_START("다리 건너기 게임을 시작합니다."), INPUT_BRIDGE_LENGTH("다리의 길이를 입력해주세요."), INPUT_BRIDGE_STAGE("이동할 칸을 선택해주세요. (위: %s, 아래: %s)"); From 6be24979df888dd9be4bf7d71c0f2c08ce283350 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Thu, 24 Aug 2023 01:25:39 +0900 Subject: [PATCH 35/73] =?UTF-8?q?feat:=20printMap=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/OutputView.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/bridge/OutputView.java b/src/main/java/bridge/OutputView.java index 166e82987b8..d969221b665 100644 --- a/src/main/java/bridge/OutputView.java +++ b/src/main/java/bridge/OutputView.java @@ -10,7 +10,8 @@ public class OutputView { *

* 출력을 위해 필요한 메서드의 인자(parameter)는 자유롭게 추가하거나 변경할 수 있다. */ - public void printMap() { + public void printMap(BridgeWindowMaker bridgeWindowMaker) { + System.out.println(bridgeWindowMaker); } /** @@ -25,6 +26,7 @@ public void printErrorMessage(String errorMessage){ System.out.println(errorMessage); } + public void printInputBridgeSize() { System.out.println(GameProgressMessage.INPUT_BRIDGE_LENGTH); } From a9e4c4dfa5c410ad74595171d22781cead78333d Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Thu, 24 Aug 2023 01:25:53 +0900 Subject: [PATCH 36/73] =?UTF-8?q?feat:=20printGameStart=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/OutputView.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/bridge/OutputView.java b/src/main/java/bridge/OutputView.java index d969221b665..3322961096d 100644 --- a/src/main/java/bridge/OutputView.java +++ b/src/main/java/bridge/OutputView.java @@ -26,6 +26,9 @@ public void printErrorMessage(String errorMessage){ System.out.println(errorMessage); } + public void printGameStart() { + System.out.println(GameProgressMessage.BRIDGE_GAME_START); + } public void printInputBridgeSize() { System.out.println(GameProgressMessage.INPUT_BRIDGE_LENGTH); From 9008403f9711defac30eeb2eb9a1201453f9594c Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Thu, 24 Aug 2023 01:28:14 +0900 Subject: [PATCH 37/73] =?UTF-8?q?feat:=20BridgeStageRecord=20boolean=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/BridgeStageRecord.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/bridge/BridgeStageRecord.java b/src/main/java/bridge/BridgeStageRecord.java index 1813347aa41..03c9d0680c9 100644 --- a/src/main/java/bridge/BridgeStageRecord.java +++ b/src/main/java/bridge/BridgeStageRecord.java @@ -4,6 +4,8 @@ public class BridgeStageRecord { private static final int firstStage = 0; private static int curStage = firstStage; + private static boolean canMoveNextStage = true; + private static boolean clearsGame = false; public static int getCurStage() { return curStage; @@ -17,4 +19,17 @@ public static void reset(){ curStage = firstStage; } + public static void changeMoveStatus(boolean stageStatus){ + canMoveNextStage = stageStatus; + } + + public static void changeProgressStatus(boolean stageStatus) { + clearsGame = stageStatus; + } + + public static boolean isProgressing(){ + return canMoveNextStage && !clearsGame; + } + + } From 369b07c5bd80b2617357e27497a8423039e2f9ab Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Thu, 24 Aug 2023 01:28:28 +0900 Subject: [PATCH 38/73] =?UTF-8?q?feat:=20BridgeGameController=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BridgeGameController.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/bridge/controller/BridgeGameController.java diff --git a/src/main/java/bridge/controller/BridgeGameController.java b/src/main/java/bridge/controller/BridgeGameController.java new file mode 100644 index 00000000000..1746fac98c9 --- /dev/null +++ b/src/main/java/bridge/controller/BridgeGameController.java @@ -0,0 +1,36 @@ +package bridge.controller; + +import bridge.*; + +public class BridgeGameController { + + private final InputView inputView; + private final OutputView outputView; + private final BridgeGame bridgeGame; + + public BridgeGameController() { + this.inputView = new InputView(); + this.outputView = new OutputView(); + this.bridgeGame = new BridgeGame(); + } + + public void letGame(){ + makeGame(); + progressGame(); + } + + private void makeGame() { + outputView.printGameStart(); + int bridgeSize = inputView.readBridgeSize(); + bridgeGame.makeBridge(bridgeSize); + } + + private void progressGame() { + while (BridgeStageRecord.isProgressing()){ + String stage = inputView.readMoving(); + bridgeGame.move(stage); + outputView.printMap(bridgeGame.getBridgeWindowMaker()); + } + } + +} From 7e039656259556dbedad6661edf4f3a03f5395a8 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 21:33:52 +0900 Subject: [PATCH 39/73] =?UTF-8?q?refactor:=20BridgeMap/Element=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/BridgeGame.java | 10 +++---- ...{BridgeWindowMaker.java => BridgeMap.java} | 28 +++++++++---------- ...ndowElement.java => BridgeMapElement.java} | 6 ++-- src/main/java/bridge/OutputView.java | 4 +-- .../controller/BridgeGameController.java | 4 ++- src/test/java/bridge/BridgeWindowTest.java | 4 +-- 6 files changed, 29 insertions(+), 27 deletions(-) rename src/main/java/bridge/{BridgeWindowMaker.java => BridgeMap.java} (56%) rename src/main/java/bridge/{BridgeWindowElement.java => BridgeMapElement.java} (69%) diff --git a/src/main/java/bridge/BridgeGame.java b/src/main/java/bridge/BridgeGame.java index 0b244ad1271..eef2054b7aa 100644 --- a/src/main/java/bridge/BridgeGame.java +++ b/src/main/java/bridge/BridgeGame.java @@ -7,12 +7,12 @@ public class BridgeGame { private static final boolean CLEARS_GAME = true; private final BridgeMaker bridgeMaker; - private final BridgeWindowMaker bridgeWindowMaker; + private final BridgeMap bridgeMap; private Bridge bridge; public BridgeGame() { this.bridgeMaker = new BridgeMaker(new BridgeRandomNumberGenerator()); - this.bridgeWindowMaker = new BridgeWindowMaker(); + this.bridgeMap = new BridgeMap(); } public void makeBridge(int bridge){ @@ -28,7 +28,7 @@ public void makeBridge(int bridge){ public void move(String bridgeStageCommand) { int curStage = BridgeStageRecord.getCurStage(); boolean canMoveStage = bridge.canMoveStage(bridgeStageCommand, curStage); - bridgeWindowMaker.moveStair(bridgeStageCommand, canMoveStage); + bridgeMap.moveStair(bridgeStageCommand, canMoveStage); checksStageStatus(canMoveStage); BridgeStageRecord.nextStage(); } @@ -48,7 +48,7 @@ public void checksStageStatus(boolean canMoveStage){ BridgeStageRecord.changeMoveStatus(canMoveStage); } - public BridgeWindowMaker getBridgeWindowMaker() { - return bridgeWindowMaker; + public BridgeMap getBridgeMap() { + return bridgeMap; } } diff --git a/src/main/java/bridge/BridgeWindowMaker.java b/src/main/java/bridge/BridgeMap.java similarity index 56% rename from src/main/java/bridge/BridgeWindowMaker.java rename to src/main/java/bridge/BridgeMap.java index 0b32a170702..b05f1211963 100644 --- a/src/main/java/bridge/BridgeWindowMaker.java +++ b/src/main/java/bridge/BridgeMap.java @@ -3,23 +3,23 @@ import java.util.ArrayList; import java.util.List; -public class BridgeWindowMaker { +public class BridgeMap { private static final int INIT_SIZE = 2; private static final int LENGTH_ONE = 1; - private final List upStair = new ArrayList<>(); - private final List downStair = new ArrayList<>(); + private final List upStair = new ArrayList<>(); + private final List downStair = new ArrayList<>(); - public BridgeWindowMaker(){ + public BridgeMap(){ init(); } private void init(){ - upStair.add(BridgeWindowElement.START); - upStair.add(BridgeWindowElement.END); - downStair.add(BridgeWindowElement.START); - downStair.add(BridgeWindowElement.END); + upStair.add(BridgeMapElement.START); + upStair.add(BridgeMapElement.END); + downStair.add(BridgeMapElement.START); + downStair.add(BridgeMapElement.END); } public void reset() { @@ -29,14 +29,14 @@ public void reset() { } public void moveStair(String bridgeStair, boolean canMoveStage) { inputDivision(); - BridgeWindowElement windowElement = BridgeWindowElement.getStageWindowElement(canMoveStage); + BridgeMapElement windowElement = BridgeMapElement.getStageWindowElement(canMoveStage); if (GameCommand.isBridgeStageCommandU(bridgeStair)) { upStair.add(getInsertMiddle(upStair), windowElement); - downStair.add(getInsertMiddle(downStair), BridgeWindowElement.BLANK); + downStair.add(getInsertMiddle(downStair), BridgeMapElement.BLANK); return; } - upStair.add(getInsertMiddle(upStair), BridgeWindowElement.BLANK); + upStair.add(getInsertMiddle(upStair), BridgeMapElement.BLANK); downStair.add(getInsertMiddle(downStair), windowElement); } @@ -45,11 +45,11 @@ private void inputDivision(){ if (upStair.size() == INIT_SIZE){ return; } - upStair.add(getInsertMiddle(upStair), BridgeWindowElement.DIVISION); - downStair.add(getInsertMiddle(downStair), BridgeWindowElement.DIVISION); + upStair.add(getInsertMiddle(upStair), BridgeMapElement.DIVISION); + downStair.add(getInsertMiddle(downStair), BridgeMapElement.DIVISION); } - private int getInsertMiddle(List stair){ + private int getInsertMiddle(List stair){ return stair.size() - LENGTH_ONE; } diff --git a/src/main/java/bridge/BridgeWindowElement.java b/src/main/java/bridge/BridgeMapElement.java similarity index 69% rename from src/main/java/bridge/BridgeWindowElement.java rename to src/main/java/bridge/BridgeMapElement.java index 42fa7d3290c..e3aeca3410c 100644 --- a/src/main/java/bridge/BridgeWindowElement.java +++ b/src/main/java/bridge/BridgeMapElement.java @@ -1,6 +1,6 @@ package bridge; -public enum BridgeWindowElement { +public enum BridgeMapElement { START("[ "), SUCCESS("O"), FAIL("X"), @@ -10,7 +10,7 @@ public enum BridgeWindowElement { private final String value; - BridgeWindowElement(String value) { + BridgeMapElement(String value) { this.value = value; } @@ -19,7 +19,7 @@ public String toString() { return value; } - public static BridgeWindowElement getStageWindowElement(boolean canMoveStage) { + public static BridgeMapElement getStageWindowElement(boolean canMoveStage) { if (canMoveStage){ return SUCCESS; } diff --git a/src/main/java/bridge/OutputView.java b/src/main/java/bridge/OutputView.java index 3322961096d..21abef408ca 100644 --- a/src/main/java/bridge/OutputView.java +++ b/src/main/java/bridge/OutputView.java @@ -10,8 +10,8 @@ public class OutputView { *

* 출력을 위해 필요한 메서드의 인자(parameter)는 자유롭게 추가하거나 변경할 수 있다. */ - public void printMap(BridgeWindowMaker bridgeWindowMaker) { - System.out.println(bridgeWindowMaker); + public void printMap(BridgeMap bridgeMap) { + System.out.println(bridgeMap); } /** diff --git a/src/main/java/bridge/controller/BridgeGameController.java b/src/main/java/bridge/controller/BridgeGameController.java index 1746fac98c9..7ae234f87c8 100644 --- a/src/main/java/bridge/controller/BridgeGameController.java +++ b/src/main/java/bridge/controller/BridgeGameController.java @@ -29,8 +29,10 @@ private void progressGame() { while (BridgeStageRecord.isProgressing()){ String stage = inputView.readMoving(); bridgeGame.move(stage); - outputView.printMap(bridgeGame.getBridgeWindowMaker()); + outputView.printMap(bridgeGame.getBridgeMap()); } } + + } diff --git a/src/test/java/bridge/BridgeWindowTest.java b/src/test/java/bridge/BridgeWindowTest.java index 56fd6d8737c..863c6a78ee3 100644 --- a/src/test/java/bridge/BridgeWindowTest.java +++ b/src/test/java/bridge/BridgeWindowTest.java @@ -8,8 +8,8 @@ class BridgeWindowTest { @Test @DisplayName("입력한 칸이 성공했을 때 SUCCESS를 반환하는지 확인한다.") void getBridgeWindowElement(){ - BridgeWindowElement bridgeWindowElement = BridgeWindowElement.getStageWindowElement(true); - assertThat(bridgeWindowElement).isEqualTo(BridgeWindowElement.SUCCESS); + BridgeMapElement bridgeWindowElement = BridgeMapElement.getStageWindowElement(true); + assertThat(bridgeWindowElement).isEqualTo(BridgeMapElement.SUCCESS); } } From 983d80953d85bf0bec43532264a7f9b83012a774 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 21:54:39 +0900 Subject: [PATCH 40/73] =?UTF-8?q?feat:=20ErrorMessage=20=EA=B2=8C=EC=9E=84?= =?UTF-8?q?=20=EB=8B=A4=EC=8B=9C=20=EC=8B=9C=EB=8F=84=20=EC=97=AC=EB=B6=80?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/ErrorMessage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/bridge/ErrorMessage.java b/src/main/java/bridge/ErrorMessage.java index f35a6c3dd83..0b543c30e06 100644 --- a/src/main/java/bridge/ErrorMessage.java +++ b/src/main/java/bridge/ErrorMessage.java @@ -5,6 +5,7 @@ public enum ErrorMessage { // bridge BRIDGE_LENGTH_ERROR("다리 길이는 %s~%s 사이의 숫자입니다."), BRIDGE_STAGE_COMMAND_ERROR("이동할 칸은 %s 혹은 %s 입니다."), + BRIDGE_RETRY_COMMAND_ERROR("게임 다시 시도 여부 명령어는 '%s' 혹은 '%s' 입니다."), // global INPUT_NOT_NUMBER_ERROR("숫자가 아닙니다."), From c7f33213799855ab2ee700a9f5cf1ee46167f5fe Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 21:54:51 +0900 Subject: [PATCH 41/73] =?UTF-8?q?feat:=20GameCommand=20=EA=B2=8C=EC=9E=84?= =?UTF-8?q?=20=EB=8B=A4=EC=8B=9C=20=EC=8B=9C=EB=8F=84=20=EC=97=AC=EB=B6=80?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/GameCommand.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/bridge/GameCommand.java b/src/main/java/bridge/GameCommand.java index f8fdb78e22e..1c75fb77498 100644 --- a/src/main/java/bridge/GameCommand.java +++ b/src/main/java/bridge/GameCommand.java @@ -2,7 +2,9 @@ public enum GameCommand { UP_STAIR("U"), - DOWN_STAIR("D"); + DOWN_STAIR("D"), + BRIDGE_RETRY("R"), + BRIDGE_QUITE("Q"); private final static int DOWN_RANDOM_NUMBER = 0; @@ -35,4 +37,9 @@ public static boolean isNotBridgeStageCommand(String bridgeStage) { public static boolean isBridgeStageCommandU(String bridgeStage){ return bridgeStage.equals(UP_STAIR.getCommand()); } + + public static boolean isNotBridgeRetryCommand(String bridgeRetry){ + return !bridgeRetry.equals(BRIDGE_RETRY.getCommand()) && !bridgeRetry.equals(BRIDGE_QUITE.getCommand()); + } + } From 0ded25d9bbcee4538ddd460cf09b6e60bd24dab8 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 21:55:12 +0900 Subject: [PATCH 42/73] =?UTF-8?q?feat:=20INPUT=5FBRIDGE=5FRETRY=20?= =?UTF-8?q?=EA=B2=8C=EC=9E=84=20=EB=8B=A4=EC=8B=9C=20=EC=8B=9C=EB=8F=84=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/GameProgressMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/bridge/GameProgressMessage.java b/src/main/java/bridge/GameProgressMessage.java index 89125a4b17a..012acde12be 100644 --- a/src/main/java/bridge/GameProgressMessage.java +++ b/src/main/java/bridge/GameProgressMessage.java @@ -4,7 +4,8 @@ public enum GameProgressMessage { BRIDGE_GAME_START("다리 건너기 게임을 시작합니다."), INPUT_BRIDGE_LENGTH("다리의 길이를 입력해주세요."), - INPUT_BRIDGE_STAGE("이동할 칸을 선택해주세요. (위: %s, 아래: %s)"); + INPUT_BRIDGE_STAGE("이동할 칸을 선택해주세요. (위: %s, 아래: %s)"), + INPUT_BRIDGE_RETRY("게임을 다시 시도할지 여부를 입력해주세요. (재시도: %s, 종료: %s)"); private final String message; From b0aa52b3839ec1da059880a5ad71a41b9083dd45 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 21:55:26 +0900 Subject: [PATCH 43/73] =?UTF-8?q?feat:=20validateBridgeRetry=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/InputValidator.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/bridge/InputValidator.java b/src/main/java/bridge/InputValidator.java index 959b2742de4..5f5ff6eeb94 100644 --- a/src/main/java/bridge/InputValidator.java +++ b/src/main/java/bridge/InputValidator.java @@ -13,6 +13,16 @@ public void validateBridgeSize(String bridgeSize){ validateBridgeLength(bridgeSize); } + public void validateBridgeStage(String bridgeStage) { + validateInputUpperEnglish(bridgeStage); + validateBridgeStageCommand(bridgeStage); + } + + public void validateBridgeRetry(String retryCommand) { + validateInputUpperEnglish(retryCommand); + validateInputRetryCommand(retryCommand); + } + private void validateInputNumber(String number) { if (isNotNumeric(number)) { throw new IllegalArgumentException(ErrorMessage.INPUT_NOT_NUMBER_ERROR.getMessage()); @@ -34,11 +44,6 @@ private boolean isNotBridgeLength(int bridgeLength){ return bridgeLength < MIN_SIZE || bridgeLength > MAX_SIZE; } - public void validateBridgeStage(String bridgeStage) { - validateInputUpperEnglish(bridgeStage); - validateBridgeStageCommand(bridgeStage); - } - private void validateInputUpperEnglish(String bridgeStage) { if (isNotUpperEnglish(bridgeStage)){ throw new IllegalArgumentException(ErrorMessage.INPUT_NOT_UPPER_ENGLISH_ERROR.getMessage()); @@ -56,5 +61,10 @@ private void validateBridgeStageCommand(String bridgeStage) { } } - + private void validateInputRetryCommand(String retryCommand) { + if (GameCommand.isNotBridgeRetryCommand(retryCommand)){ + throw new IllegalArgumentException(String.format(ErrorMessage.BRIDGE_STAGE_COMMAND_ERROR.getMessage() + , GameCommand.BRIDGE_RETRY, GameCommand.BRIDGE_QUITE)); + } + } } From adf59ac87383528d83b0053e3fb41046b93deb96 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 21:55:52 +0900 Subject: [PATCH 44/73] =?UTF-8?q?feat:=20InputView=20readGameCommand=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/InputView.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/bridge/InputView.java b/src/main/java/bridge/InputView.java index 93d1f3e3b12..397e2a07463 100644 --- a/src/main/java/bridge/InputView.java +++ b/src/main/java/bridge/InputView.java @@ -64,7 +64,23 @@ private String inputBridgeStage() { /** * 사용자가 게임을 다시 시도할지 종료할지 여부를 입력받는다. */ - public String readGameCommand() { - return null; + public String readGameCommand(){ + String input; + do{ + input = inputRetryCommand(); + }while (input == null); + return input; + } + + private String inputRetryCommand() { + outputView.printInputBridgeRetry(); + String retryCommand = Console.readLine(); + try { + inputValidator.validateBridgeRetry(retryCommand); + } catch (IllegalArgumentException e){ + System.out.println(e.getMessage()); + return null; + } + return retryCommand; } } From 67e9624bfbf22d5b4a00056c99245cc498ffb04a Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 21:56:13 +0900 Subject: [PATCH 45/73] =?UTF-8?q?feat:=20OutputView=20printInputBridgeRetr?= =?UTF-8?q?y=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/OutputView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/bridge/OutputView.java b/src/main/java/bridge/OutputView.java index 21abef408ca..43ec36d615c 100644 --- a/src/main/java/bridge/OutputView.java +++ b/src/main/java/bridge/OutputView.java @@ -39,4 +39,10 @@ public void printInputBridgeStage(){ , GameCommand.UP_STAIR, GameCommand.DOWN_STAIR); System.out.println(message); } + + public void printInputBridgeRetry(){ + String message = String.format(GameProgressMessage.INPUT_BRIDGE_RETRY.toString() + , GameCommand.BRIDGE_RETRY, GameCommand.BRIDGE_QUITE); + System.out.println(message); + } } From 582a0149eca611cc585c0f16839e92fe299b1ab9 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 21:56:33 +0900 Subject: [PATCH 46/73] =?UTF-8?q?test:=20=EC=9E=AC=EC=8B=9C=EB=8F=84=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EB=AA=85=EB=A0=B9=EC=96=B4=EA=B0=80=20?= =?UTF-8?q?=EB=8C=80=EB=AC=B8=EC=9E=90=20=EC=98=81=EC=96=B4=EA=B0=80=20?= =?UTF-8?q?=EC=95=84=EB=8B=88=EB=A9=B4=20=EC=97=90=EB=9F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/InputValidatorTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/java/bridge/InputValidatorTest.java b/src/test/java/bridge/InputValidatorTest.java index 3d57e4d2e26..993a063f3bf 100644 --- a/src/test/java/bridge/InputValidatorTest.java +++ b/src/test/java/bridge/InputValidatorTest.java @@ -36,6 +36,15 @@ void validateBridgeStage(){ .isInstanceOf(IllegalArgumentException.class); } + @Test + @DisplayName("재시도 여부 명령어가 대문자 영어가 아니면 에러가 발생한다.") + void validateBridgeRetryUpperEnglish(){ + assertThatThrownBy(() -> inputValidator.validateBridgeRetry("r")) + .isInstanceOf(IllegalArgumentException.class); + } + + + From 8a53115f9c5fac5477aedc55afbc85f6ebad64a5 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 21:56:45 +0900 Subject: [PATCH 47/73] =?UTF-8?q?test:=20=EC=9E=AC=EC=8B=9C=EB=8F=84=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EB=AA=85=EB=A0=B9=EC=96=B4=EA=B0=80=20'R'?= =?UTF-8?q?=20=ED=98=B9=EC=9D=80=20'Q'=EA=B0=80=20=EC=95=84=EB=8B=88?= =?UTF-8?q?=EB=A9=B4=20=EC=97=90=EB=9F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/InputValidatorTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/bridge/InputValidatorTest.java b/src/test/java/bridge/InputValidatorTest.java index 993a063f3bf..b57d63bd0bd 100644 --- a/src/test/java/bridge/InputValidatorTest.java +++ b/src/test/java/bridge/InputValidatorTest.java @@ -43,7 +43,12 @@ void validateBridgeRetryUpperEnglish(){ .isInstanceOf(IllegalArgumentException.class); } - + @Test + @DisplayName("재시도 여부 명령어가 'R' 혹은 'Q'가 아니면 에러가 발생한다.") + void validateBridgeRetry(){ + assertThatThrownBy(() -> inputValidator.validateBridgeRetry("T")) + .isInstanceOf(IllegalArgumentException.class); + } From 6284da326b2e885c069265c4cbe40ba74f55083d Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 21:56:59 +0900 Subject: [PATCH 48/73] =?UTF-8?q?docs:=20=EC=9E=AC=EC=8B=9C=EC=9E=91=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=EB=A5=BC=20=EC=9E=85=EB=A0=A5=20=EB=B0=9B?= =?UTF-8?q?=EB=8A=94=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index bd93077166f..6aa976df68e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,6 +5,8 @@ - 3~20 사이의 숫자이다. 2. 이동할 칸을 입력 받는다. - 위 칸 -> U, 아래 칸 -> D +3. 재시작 여부를 입력 받는다. + - 재시작 -> R, 종료 -> Q - output 1. 다리 화면 출력 @@ -16,10 +18,12 @@ - 랜덤 숫자 1 -> 위 칸, 0 -> 아래 칸 2. 이동 했을 때 성공/실패를 비교한다. 3. 다리의 상태에 대한 화면을 생성한다. +4. 재시작해도 처음에 만든 다리로 재사용한다. ## 에러 처리 - 에러 발생시 [ERROR] 단어가 포함 되어있어야 한다. - 그 부분 부터 다시 입력 받는다. 1. 다리 길이는 3~20 사이의 숫자이다. -2. 이동할 칸은 'U', 'D' 이다. \ No newline at end of file +2. 이동할 칸 명령어는 'U', 'D' 이다. +3. 재시작 여부 명령어는 'R', 'Q' 이다. \ No newline at end of file From 2ed4e2304b96f5e9ec6cd77aebfb9fe60ad2a9ed Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 22:00:52 +0900 Subject: [PATCH 49/73] =?UTF-8?q?refactor:=20InputView=20isNotInputNull=20?= =?UTF-8?q?=EC=B6=94=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/InputView.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/bridge/InputView.java b/src/main/java/bridge/InputView.java index 397e2a07463..5856b1ce087 100644 --- a/src/main/java/bridge/InputView.java +++ b/src/main/java/bridge/InputView.java @@ -20,7 +20,7 @@ public int readBridgeSize() { String input; do { input = inputBridgeSize(); - } while (input == null); + } while (isNotInputNull(input)); return Integer.parseInt(input); } @@ -44,7 +44,7 @@ public String readMoving() { String input; do { input = inputBridgeStage(); - }while (input == null); + }while (isNotInputNull(input)); return input; } @@ -68,7 +68,7 @@ public String readGameCommand(){ String input; do{ input = inputRetryCommand(); - }while (input == null); + }while (isNotInputNull(input)); return input; } @@ -78,9 +78,13 @@ private String inputRetryCommand() { try { inputValidator.validateBridgeRetry(retryCommand); } catch (IllegalArgumentException e){ - System.out.println(e.getMessage()); + outputView.printErrorMessage(e.getMessage()); return null; } return retryCommand; } + + private boolean isNotInputNull(String input) { + return input == null; + } } From 9791ef079f0e5f7ce096aff2ee39398974d43b85 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 22:40:51 +0900 Subject: [PATCH 50/73] =?UTF-8?q?feat:=20BridgeGame=20retry=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/BridgeGame.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/bridge/BridgeGame.java b/src/main/java/bridge/BridgeGame.java index eef2054b7aa..9a79fc1e996 100644 --- a/src/main/java/bridge/BridgeGame.java +++ b/src/main/java/bridge/BridgeGame.java @@ -38,7 +38,10 @@ public void move(String bridgeStageCommand) { *

* 재시작을 위해 필요한 메서드의 반환 타입(return type), 인자(parameter)는 자유롭게 추가하거나 변경할 수 있다. */ - public void retry() { + public void retry(String bridgeRetryCommand) { + if (GameCommand.isBridgeRetryCommandR(bridgeRetryCommand)){ + BridgeStageRecord.reset(); + } } public void checksStageStatus(boolean canMoveStage){ From f76b694090c7d875f5bb56c05f2ea20b4da1cc6b Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 22:41:15 +0900 Subject: [PATCH 51/73] =?UTF-8?q?feat:=20BridgeStageRecord=20canNotMoveNex?= =?UTF-8?q?tStage=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/BridgeStageRecord.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/bridge/BridgeStageRecord.java b/src/main/java/bridge/BridgeStageRecord.java index 03c9d0680c9..3b6b37d2d56 100644 --- a/src/main/java/bridge/BridgeStageRecord.java +++ b/src/main/java/bridge/BridgeStageRecord.java @@ -17,6 +17,7 @@ public static void nextStage(){ public static void reset(){ curStage = firstStage; + canMoveNextStage = true; } public static void changeMoveStatus(boolean stageStatus){ @@ -31,5 +32,7 @@ public static boolean isProgressing(){ return canMoveNextStage && !clearsGame; } - + public static boolean canNotMoveNextStage() { + return !canMoveNextStage; + } } From f8c11eaf8c8258feb52957c8e922120af6a2cdbb Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 22:41:31 +0900 Subject: [PATCH 52/73] =?UTF-8?q?feat:=20GameCommand=20isBridgeRetryComman?= =?UTF-8?q?dR=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/GameCommand.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/bridge/GameCommand.java b/src/main/java/bridge/GameCommand.java index 1c75fb77498..f656945650b 100644 --- a/src/main/java/bridge/GameCommand.java +++ b/src/main/java/bridge/GameCommand.java @@ -42,4 +42,8 @@ public static boolean isNotBridgeRetryCommand(String bridgeRetry){ return !bridgeRetry.equals(BRIDGE_RETRY.getCommand()) && !bridgeRetry.equals(BRIDGE_QUITE.getCommand()); } + public static boolean isBridgeRetryCommandR(String bridgeRetry){ + return bridgeRetry.equals(BRIDGE_RETRY.getCommand()); + } + } From e6129d7792a82ba71b11e5ad0f75442c2392418e Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 22:41:59 +0900 Subject: [PATCH 53/73] =?UTF-8?q?feat:=20BridgeGameController=20ifCanNotMo?= =?UTF-8?q?veNextStageThenRetryGameOrQuit=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/bridge/controller/BridgeGameController.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/bridge/controller/BridgeGameController.java b/src/main/java/bridge/controller/BridgeGameController.java index 7ae234f87c8..93c77f16de3 100644 --- a/src/main/java/bridge/controller/BridgeGameController.java +++ b/src/main/java/bridge/controller/BridgeGameController.java @@ -30,9 +30,15 @@ private void progressGame() { String stage = inputView.readMoving(); bridgeGame.move(stage); outputView.printMap(bridgeGame.getBridgeMap()); + ifCanNotMoveNextStageThenRetryGameOrQuit(); } + outputView.printResult(); } - - + private void ifCanNotMoveNextStageThenRetryGameOrQuit(){ + if (BridgeStageRecord.canNotMoveNextStage()){ + bridgeGame.retry(inputView.readGameCommand()); + } + outputView.printResult(); + } } From e318e5eea0d7a6df28b18c19f12f7d76e4e580e5 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 25 Aug 2023 22:42:12 +0900 Subject: [PATCH 54/73] =?UTF-8?q?test:=20=EA=B2=8C=EC=9E=84=20=EC=9E=AC?= =?UTF-8?q?=EC=8B=9C=EC=9E=91=20=EC=8B=9C=20=ED=98=84=EC=9E=AC=20stage?= =?UTF-8?q?=EC=99=80=20=EC=9D=B4=EB=8F=99=20=EC=97=AC=EB=B6=80=EB=A5=BC=20?= =?UTF-8?q?=EA=B8=B0=EB=B3=B8=EA=B0=92=EC=9C=BC=EB=A1=9C=20reset=EB=90=98?= =?UTF-8?q?=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/BridgeGameTest.java | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/test/java/bridge/BridgeGameTest.java diff --git a/src/test/java/bridge/BridgeGameTest.java b/src/test/java/bridge/BridgeGameTest.java new file mode 100644 index 00000000000..5a0efb98ed3 --- /dev/null +++ b/src/test/java/bridge/BridgeGameTest.java @@ -0,0 +1,25 @@ +package bridge; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.*; + +class BridgeGameTest { + + BridgeGame bridgeGame = new BridgeGame(); + + @Test + @DisplayName("게임 재시작 시 현재 stage와 이동 여부를 기본값으로 reset되는지 확인하다.") + void checkBridgeStageRecordReset(){ + //given + bridgeGame.retry("R"); + BridgeStageRecord.reset(); + + //when + boolean canNotMoveNextStage = BridgeStageRecord.canNotMoveNextStage(); + + //then + assertThat(canNotMoveNextStage).isFalse(); + } + +} From 4c137561af6c2392d690db70257b2825e9b4a394 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 00:19:32 +0900 Subject: [PATCH 55/73] =?UTF-8?q?test:=20main=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/Application.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/bridge/Application.java b/src/main/java/bridge/Application.java index 5cb72dfd3de..d8da34d2562 100644 --- a/src/main/java/bridge/Application.java +++ b/src/main/java/bridge/Application.java @@ -1,8 +1,12 @@ package bridge; +import bridge.controller.BridgeGameController; + public class Application { public static void main(String[] args) { - // TODO: 프로그램 구현 + BridgeGameController bridgeGameController = new BridgeGameController( + new InputView(), new OutputView(), new BridgeGame()); + bridgeGameController.startGame(); } } From 921bc5cdd63a5c36b611bbaedfdc391780ad2da9 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 00:19:48 +0900 Subject: [PATCH 56/73] =?UTF-8?q?refactor:=20clearsAllStage=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/Bridge.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/bridge/Bridge.java b/src/main/java/bridge/Bridge.java index df2a1d2b1ee..2651f525d4b 100644 --- a/src/main/java/bridge/Bridge.java +++ b/src/main/java/bridge/Bridge.java @@ -23,7 +23,7 @@ public boolean canMoveStage(String bridgeStage, int curStage){ return bridge.get(curStage).equals(bridgeStage); } - public boolean clearsAllStage(int curStage) { - return stages() > curStage+DEFAULT_STAGE_NUM; + public boolean clearsAllStage(int curStage, boolean canMoveStage) { + return canMoveStage && stages() == curStage+DEFAULT_STAGE_NUM; } } From 8b0ab7393346adbf1c615b71b241588120238b22 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 00:20:06 +0900 Subject: [PATCH 57/73] =?UTF-8?q?refactor:=20BridgeGame=20retry=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/BridgeGame.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/bridge/BridgeGame.java b/src/main/java/bridge/BridgeGame.java index 9a79fc1e996..052b5285ecc 100644 --- a/src/main/java/bridge/BridgeGame.java +++ b/src/main/java/bridge/BridgeGame.java @@ -29,7 +29,7 @@ public void move(String bridgeStageCommand) { int curStage = BridgeStageRecord.getCurStage(); boolean canMoveStage = bridge.canMoveStage(bridgeStageCommand, curStage); bridgeMap.moveStair(bridgeStageCommand, canMoveStage); - checksStageStatus(canMoveStage); + checkStageStatus(canMoveStage); BridgeStageRecord.nextStage(); } @@ -41,11 +41,12 @@ public void move(String bridgeStageCommand) { public void retry(String bridgeRetryCommand) { if (GameCommand.isBridgeRetryCommandR(bridgeRetryCommand)){ BridgeStageRecord.reset(); + bridgeMap.reset(); } } - public void checksStageStatus(boolean canMoveStage){ - if (bridge.clearsAllStage(BridgeStageRecord.getCurStage())) { + public void checkStageStatus(boolean canMoveStage){ + if (bridge.clearsAllStage(BridgeStageRecord.getCurStage(), canMoveStage)) { BridgeStageRecord.changeProgressStatus(CLEARS_GAME); } BridgeStageRecord.changeMoveStatus(canMoveStage); From 2a9373ddf92c5f0c3305d4df4383e3a8fb2815dd Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 00:21:24 +0900 Subject: [PATCH 58/73] =?UTF-8?q?feat:=20BridgeGameController=20ifFailStag?= =?UTF-8?q?eThenRetryGameOrQuit=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/Application.java | 3 +-- .../java/bridge/controller/BridgeGameController.java | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/bridge/Application.java b/src/main/java/bridge/Application.java index d8da34d2562..758e9c0976e 100644 --- a/src/main/java/bridge/Application.java +++ b/src/main/java/bridge/Application.java @@ -5,8 +5,7 @@ public class Application { public static void main(String[] args) { - BridgeGameController bridgeGameController = new BridgeGameController( - new InputView(), new OutputView(), new BridgeGame()); + BridgeGameController bridgeGameController = new BridgeGameController(); bridgeGameController.startGame(); } } diff --git a/src/main/java/bridge/controller/BridgeGameController.java b/src/main/java/bridge/controller/BridgeGameController.java index 93c77f16de3..0d63d63aa66 100644 --- a/src/main/java/bridge/controller/BridgeGameController.java +++ b/src/main/java/bridge/controller/BridgeGameController.java @@ -14,7 +14,7 @@ public BridgeGameController() { this.bridgeGame = new BridgeGame(); } - public void letGame(){ + public void startGame(){ makeGame(); progressGame(); } @@ -30,15 +30,14 @@ private void progressGame() { String stage = inputView.readMoving(); bridgeGame.move(stage); outputView.printMap(bridgeGame.getBridgeMap()); - ifCanNotMoveNextStageThenRetryGameOrQuit(); + ifFailStageThenRetryGameOrQuit(); } - outputView.printResult(); + outputView.printResult(bridgeGame.getBridgeMap()); } - private void ifCanNotMoveNextStageThenRetryGameOrQuit(){ + private void ifFailStageThenRetryGameOrQuit(){ if (BridgeStageRecord.canNotMoveNextStage()){ bridgeGame.retry(inputView.readGameCommand()); } - outputView.printResult(); } } From 45e83111c90649658466a71d14888bdc267bbc86 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 00:22:31 +0900 Subject: [PATCH 59/73] =?UTF-8?q?feat:=20BridgeStageRecord=20get=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/BridgeMap.java | 2 +- src/main/java/bridge/BridgeStageRecord.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/bridge/BridgeMap.java b/src/main/java/bridge/BridgeMap.java index b05f1211963..85a3a42e035 100644 --- a/src/main/java/bridge/BridgeMap.java +++ b/src/main/java/bridge/BridgeMap.java @@ -27,6 +27,7 @@ public void reset() { downStair.clear(); init(); } + public void moveStair(String bridgeStair, boolean canMoveStage) { inputDivision(); BridgeMapElement windowElement = BridgeMapElement.getStageWindowElement(canMoveStage); @@ -40,7 +41,6 @@ public void moveStair(String bridgeStair, boolean canMoveStage) { downStair.add(getInsertMiddle(downStair), windowElement); } - private void inputDivision(){ if (upStair.size() == INIT_SIZE){ return; diff --git a/src/main/java/bridge/BridgeStageRecord.java b/src/main/java/bridge/BridgeStageRecord.java index 3b6b37d2d56..25d8568e3fd 100644 --- a/src/main/java/bridge/BridgeStageRecord.java +++ b/src/main/java/bridge/BridgeStageRecord.java @@ -6,6 +6,7 @@ public class BridgeStageRecord { private static int curStage = firstStage; private static boolean canMoveNextStage = true; private static boolean clearsGame = false; + private static int totalAttemptCount = 1; public static int getCurStage() { return curStage; @@ -18,6 +19,7 @@ public static void nextStage(){ public static void reset(){ curStage = firstStage; canMoveNextStage = true; + totalAttemptCount++; } public static void changeMoveStatus(boolean stageStatus){ @@ -35,4 +37,12 @@ public static boolean isProgressing(){ public static boolean canNotMoveNextStage() { return !canMoveNextStage; } + + public static boolean isClearsGame() { + return clearsGame; + } + + public static int getTotalAttemptCount() { + return totalAttemptCount; + } } From ac232827040b5c93b4d44a98f2c0d5461692d19b Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 00:23:15 +0900 Subject: [PATCH 60/73] =?UTF-8?q?feat:=20GameProgressMessage=20=EB=A9=94?= =?UTF-8?q?=EC=84=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/GameProgressMessage.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/bridge/GameProgressMessage.java b/src/main/java/bridge/GameProgressMessage.java index 012acde12be..e0bae6fd2d5 100644 --- a/src/main/java/bridge/GameProgressMessage.java +++ b/src/main/java/bridge/GameProgressMessage.java @@ -3,9 +3,16 @@ public enum GameProgressMessage { BRIDGE_GAME_START("다리 건너기 게임을 시작합니다."), + + // input INPUT_BRIDGE_LENGTH("다리의 길이를 입력해주세요."), INPUT_BRIDGE_STAGE("이동할 칸을 선택해주세요. (위: %s, 아래: %s)"), - INPUT_BRIDGE_RETRY("게임을 다시 시도할지 여부를 입력해주세요. (재시도: %s, 종료: %s)"); + INPUT_BRIDGE_RETRY("게임을 다시 시도할지 여부를 입력해주세요. (재시도: %s, 종료: %s)"), + + //output + OUTPUT_FINAL_GAME_RESULT("최종 게임 결과"), + OUTPUT_BRIDGE_SUCCESS_OR_NOT("게임 성공 여부: %s"), + OUTPUT_BRIDGE_ATTEMPT_RESULT("총 시도한 횟수: %d"); private final String message; From 36af97b533ceea07105cb084b5ac54fd79e81369 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 00:23:28 +0900 Subject: [PATCH 61/73] =?UTF-8?q?feat:=20GameResult=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/GameResult.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/bridge/GameResult.java diff --git a/src/main/java/bridge/GameResult.java b/src/main/java/bridge/GameResult.java new file mode 100644 index 00000000000..2e900e7699d --- /dev/null +++ b/src/main/java/bridge/GameResult.java @@ -0,0 +1,26 @@ +package bridge; + +public enum GameResult { + + + GAME_SUCCESS("성공"), + GAME_FAILED("실패"); + + private final String message; + + GameResult(String message) { + this.message = message; + } + + @Override + public String toString() { + return message; + } + + public static String gameResult(){ + if (BridgeStageRecord.isClearsGame()){ + return GAME_SUCCESS.message; + } + return GAME_FAILED.message; + } +} From 7cd8fc177f2a3e4ca2d049cf8a3135f78e18a67e Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 00:23:56 +0900 Subject: [PATCH 62/73] =?UTF-8?q?feat:=20=EC=9E=85=EC=B6=9C=EB=A0=A5=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/InputView.java | 1 + src/main/java/bridge/OutputView.java | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/bridge/InputView.java b/src/main/java/bridge/InputView.java index 5856b1ce087..84b8107afe7 100644 --- a/src/main/java/bridge/InputView.java +++ b/src/main/java/bridge/InputView.java @@ -28,6 +28,7 @@ public int readBridgeSize() { private String inputBridgeSize() { outputView.printInputBridgeSize(); String bridgeSize = Console.readLine(); + outputView.printEnter(); try { inputValidator.validateBridgeSize(bridgeSize); } catch (IllegalArgumentException e){ diff --git a/src/main/java/bridge/OutputView.java b/src/main/java/bridge/OutputView.java index 43ec36d615c..361b070cc32 100644 --- a/src/main/java/bridge/OutputView.java +++ b/src/main/java/bridge/OutputView.java @@ -19,7 +19,13 @@ public void printMap(BridgeMap bridgeMap) { *

* 출력을 위해 필요한 메서드의 인자(parameter)는 자유롭게 추가하거나 변경할 수 있다. */ - public void printResult() { + public void printResult(BridgeMap bridgeMap) { + System.out.println(GameProgressMessage.OUTPUT_FINAL_GAME_RESULT); + System.out.println(bridgeMap); + System.out.println(String.format(GameProgressMessage.OUTPUT_BRIDGE_SUCCESS_OR_NOT.toString() + , GameResult.gameResult())); + System.out.println(String.format(GameProgressMessage.OUTPUT_BRIDGE_ATTEMPT_RESULT.toString() + , BridgeStageRecord.getTotalAttemptCount())); } public void printErrorMessage(String errorMessage){ @@ -28,6 +34,7 @@ public void printErrorMessage(String errorMessage){ public void printGameStart() { System.out.println(GameProgressMessage.BRIDGE_GAME_START); + System.out.println(); } public void printInputBridgeSize() { @@ -35,7 +42,7 @@ public void printInputBridgeSize() { } public void printInputBridgeStage(){ - String message = String.format(GameProgressMessage.INPUT_BRIDGE_STAGE.toString() + String message = String.format(GameProgressMessage.INPUT_BRIDGE_STAGE.toString() , GameCommand.UP_STAIR, GameCommand.DOWN_STAIR); System.out.println(message); } @@ -45,4 +52,8 @@ public void printInputBridgeRetry(){ , GameCommand.BRIDGE_RETRY, GameCommand.BRIDGE_QUITE); System.out.println(message); } + + public void printEnter(){ + System.out.println(); + } } From 4d6a252d960f8e0526bc5cc9fb0a95745e233dba Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 00:29:59 +0900 Subject: [PATCH 63/73] =?UTF-8?q?refactor:=20=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/{ => constant}/BridgeMapElement.java | 2 +- src/main/java/bridge/{ => constant}/ErrorMessage.java | 2 +- src/main/java/bridge/{ => constant}/GameCommand.java | 2 +- .../java/bridge/{ => constant}/GameProgressMessage.java | 2 +- src/main/java/bridge/{ => constant}/GameResult.java | 4 +++- src/main/java/bridge/controller/BridgeGameController.java | 5 ++++- src/main/java/bridge/{ => model}/Bridge.java | 2 +- src/main/java/bridge/{ => model}/BridgeGame.java | 5 ++++- src/main/java/bridge/{ => model}/BridgeMaker.java | 5 ++++- src/main/java/bridge/{ => model}/BridgeMap.java | 5 ++++- src/main/java/bridge/{ => model}/BridgeStageRecord.java | 2 +- src/main/java/bridge/{ => view}/InputValidator.java | 5 ++++- src/main/java/bridge/{ => view}/InputView.java | 2 +- src/main/java/bridge/{ => view}/OutputView.java | 8 +++++++- src/test/java/bridge/ApplicationTest.java | 1 + src/test/java/bridge/BridgeGameTest.java | 2 ++ src/test/java/bridge/BridgeMakerTest.java | 2 ++ src/test/java/bridge/BridgeWindowTest.java | 1 + src/test/java/bridge/InputValidatorTest.java | 1 + 19 files changed, 44 insertions(+), 14 deletions(-) rename src/main/java/bridge/{ => constant}/BridgeMapElement.java (95%) rename src/main/java/bridge/{ => constant}/ErrorMessage.java (96%) rename src/main/java/bridge/{ => constant}/GameCommand.java (98%) rename src/main/java/bridge/{ => constant}/GameProgressMessage.java (96%) rename src/main/java/bridge/{ => constant}/GameResult.java (87%) rename src/main/java/bridge/{ => model}/Bridge.java (97%) rename src/main/java/bridge/{ => model}/BridgeGame.java (94%) rename src/main/java/bridge/{ => model}/BridgeMaker.java (89%) rename src/main/java/bridge/{ => model}/BridgeMap.java (95%) rename src/main/java/bridge/{ => model}/BridgeStageRecord.java (98%) rename src/main/java/bridge/{ => view}/InputValidator.java (96%) rename src/main/java/bridge/{ => view}/InputView.java (99%) rename src/main/java/bridge/{ => view}/OutputView.java (90%) diff --git a/src/main/java/bridge/BridgeMapElement.java b/src/main/java/bridge/constant/BridgeMapElement.java similarity index 95% rename from src/main/java/bridge/BridgeMapElement.java rename to src/main/java/bridge/constant/BridgeMapElement.java index e3aeca3410c..0bd688e2cce 100644 --- a/src/main/java/bridge/BridgeMapElement.java +++ b/src/main/java/bridge/constant/BridgeMapElement.java @@ -1,4 +1,4 @@ -package bridge; +package bridge.constant; public enum BridgeMapElement { START("[ "), diff --git a/src/main/java/bridge/ErrorMessage.java b/src/main/java/bridge/constant/ErrorMessage.java similarity index 96% rename from src/main/java/bridge/ErrorMessage.java rename to src/main/java/bridge/constant/ErrorMessage.java index 0b543c30e06..9af68a17ce4 100644 --- a/src/main/java/bridge/ErrorMessage.java +++ b/src/main/java/bridge/constant/ErrorMessage.java @@ -1,4 +1,4 @@ -package bridge; +package bridge.constant; public enum ErrorMessage { diff --git a/src/main/java/bridge/GameCommand.java b/src/main/java/bridge/constant/GameCommand.java similarity index 98% rename from src/main/java/bridge/GameCommand.java rename to src/main/java/bridge/constant/GameCommand.java index f656945650b..3aa4cfc1724 100644 --- a/src/main/java/bridge/GameCommand.java +++ b/src/main/java/bridge/constant/GameCommand.java @@ -1,4 +1,4 @@ -package bridge; +package bridge.constant; public enum GameCommand { UP_STAIR("U"), diff --git a/src/main/java/bridge/GameProgressMessage.java b/src/main/java/bridge/constant/GameProgressMessage.java similarity index 96% rename from src/main/java/bridge/GameProgressMessage.java rename to src/main/java/bridge/constant/GameProgressMessage.java index e0bae6fd2d5..6830e423225 100644 --- a/src/main/java/bridge/GameProgressMessage.java +++ b/src/main/java/bridge/constant/GameProgressMessage.java @@ -1,4 +1,4 @@ -package bridge; +package bridge.constant; public enum GameProgressMessage { diff --git a/src/main/java/bridge/GameResult.java b/src/main/java/bridge/constant/GameResult.java similarity index 87% rename from src/main/java/bridge/GameResult.java rename to src/main/java/bridge/constant/GameResult.java index 2e900e7699d..221d21f7144 100644 --- a/src/main/java/bridge/GameResult.java +++ b/src/main/java/bridge/constant/GameResult.java @@ -1,4 +1,6 @@ -package bridge; +package bridge.constant; + +import bridge.model.BridgeStageRecord; public enum GameResult { diff --git a/src/main/java/bridge/controller/BridgeGameController.java b/src/main/java/bridge/controller/BridgeGameController.java index 0d63d63aa66..44d50426976 100644 --- a/src/main/java/bridge/controller/BridgeGameController.java +++ b/src/main/java/bridge/controller/BridgeGameController.java @@ -1,6 +1,9 @@ package bridge.controller; -import bridge.*; +import bridge.model.BridgeGame; +import bridge.model.BridgeStageRecord; +import bridge.view.InputView; +import bridge.view.OutputView; public class BridgeGameController { diff --git a/src/main/java/bridge/Bridge.java b/src/main/java/bridge/model/Bridge.java similarity index 97% rename from src/main/java/bridge/Bridge.java rename to src/main/java/bridge/model/Bridge.java index 2651f525d4b..8cdc8ffca7c 100644 --- a/src/main/java/bridge/Bridge.java +++ b/src/main/java/bridge/model/Bridge.java @@ -1,4 +1,4 @@ -package bridge; +package bridge.model; import java.util.ArrayList; import java.util.Collections; diff --git a/src/main/java/bridge/BridgeGame.java b/src/main/java/bridge/model/BridgeGame.java similarity index 94% rename from src/main/java/bridge/BridgeGame.java rename to src/main/java/bridge/model/BridgeGame.java index 052b5285ecc..fc208920f6b 100644 --- a/src/main/java/bridge/BridgeGame.java +++ b/src/main/java/bridge/model/BridgeGame.java @@ -1,4 +1,7 @@ -package bridge; +package bridge.model; + +import bridge.BridgeRandomNumberGenerator; +import bridge.constant.GameCommand; /** * 다리 건너기 게임을 관리하는 클래스 diff --git a/src/main/java/bridge/BridgeMaker.java b/src/main/java/bridge/model/BridgeMaker.java similarity index 89% rename from src/main/java/bridge/BridgeMaker.java rename to src/main/java/bridge/model/BridgeMaker.java index 6e7dc6779d9..d802e370f82 100644 --- a/src/main/java/bridge/BridgeMaker.java +++ b/src/main/java/bridge/model/BridgeMaker.java @@ -1,4 +1,7 @@ -package bridge; +package bridge.model; + +import bridge.BridgeNumberGenerator; +import bridge.constant.GameCommand; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/bridge/BridgeMap.java b/src/main/java/bridge/model/BridgeMap.java similarity index 95% rename from src/main/java/bridge/BridgeMap.java rename to src/main/java/bridge/model/BridgeMap.java index 85a3a42e035..b990f00c953 100644 --- a/src/main/java/bridge/BridgeMap.java +++ b/src/main/java/bridge/model/BridgeMap.java @@ -1,4 +1,7 @@ -package bridge; +package bridge.model; + +import bridge.constant.BridgeMapElement; +import bridge.constant.GameCommand; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/bridge/BridgeStageRecord.java b/src/main/java/bridge/model/BridgeStageRecord.java similarity index 98% rename from src/main/java/bridge/BridgeStageRecord.java rename to src/main/java/bridge/model/BridgeStageRecord.java index 25d8568e3fd..2b3dcd3c588 100644 --- a/src/main/java/bridge/BridgeStageRecord.java +++ b/src/main/java/bridge/model/BridgeStageRecord.java @@ -1,4 +1,4 @@ -package bridge; +package bridge.model; public class BridgeStageRecord { diff --git a/src/main/java/bridge/InputValidator.java b/src/main/java/bridge/view/InputValidator.java similarity index 96% rename from src/main/java/bridge/InputValidator.java rename to src/main/java/bridge/view/InputValidator.java index 5f5ff6eeb94..84be3f63ffe 100644 --- a/src/main/java/bridge/InputValidator.java +++ b/src/main/java/bridge/view/InputValidator.java @@ -1,6 +1,9 @@ -package bridge; +package bridge.view; +import bridge.constant.ErrorMessage; +import bridge.constant.GameCommand; + public class InputValidator { private static final int MIN_SIZE = 3; diff --git a/src/main/java/bridge/InputView.java b/src/main/java/bridge/view/InputView.java similarity index 99% rename from src/main/java/bridge/InputView.java rename to src/main/java/bridge/view/InputView.java index 84b8107afe7..61f2d4d2bdc 100644 --- a/src/main/java/bridge/InputView.java +++ b/src/main/java/bridge/view/InputView.java @@ -1,4 +1,4 @@ -package bridge; +package bridge.view; import camp.nextstep.edu.missionutils.Console; /** * 사용자로부터 입력을 받는 역할을 한다. diff --git a/src/main/java/bridge/OutputView.java b/src/main/java/bridge/view/OutputView.java similarity index 90% rename from src/main/java/bridge/OutputView.java rename to src/main/java/bridge/view/OutputView.java index 361b070cc32..70f15b5a35d 100644 --- a/src/main/java/bridge/OutputView.java +++ b/src/main/java/bridge/view/OutputView.java @@ -1,4 +1,10 @@ -package bridge; +package bridge.view; + +import bridge.model.BridgeMap; +import bridge.model.BridgeStageRecord; +import bridge.constant.GameCommand; +import bridge.constant.GameProgressMessage; +import bridge.constant.GameResult; /** * 사용자에게 게임 진행 상황과 결과를 출력하는 역할을 한다. diff --git a/src/test/java/bridge/ApplicationTest.java b/src/test/java/bridge/ApplicationTest.java index 1a163ec0a2a..51b833ff850 100644 --- a/src/test/java/bridge/ApplicationTest.java +++ b/src/test/java/bridge/ApplicationTest.java @@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.util.Lists.newArrayList; +import bridge.model.BridgeMaker; import camp.nextstep.edu.missionutils.test.NsTest; import java.util.List; import org.junit.jupiter.api.Test; diff --git a/src/test/java/bridge/BridgeGameTest.java b/src/test/java/bridge/BridgeGameTest.java index 5a0efb98ed3..b5229df18d1 100644 --- a/src/test/java/bridge/BridgeGameTest.java +++ b/src/test/java/bridge/BridgeGameTest.java @@ -1,5 +1,7 @@ package bridge; +import bridge.model.BridgeGame; +import bridge.model.BridgeStageRecord; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.*; diff --git a/src/test/java/bridge/BridgeMakerTest.java b/src/test/java/bridge/BridgeMakerTest.java index 7cda06773e0..ee1666e02e8 100644 --- a/src/test/java/bridge/BridgeMakerTest.java +++ b/src/test/java/bridge/BridgeMakerTest.java @@ -1,5 +1,7 @@ package bridge; +import bridge.model.Bridge; +import bridge.model.BridgeMaker; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/bridge/BridgeWindowTest.java b/src/test/java/bridge/BridgeWindowTest.java index 863c6a78ee3..7e98a431424 100644 --- a/src/test/java/bridge/BridgeWindowTest.java +++ b/src/test/java/bridge/BridgeWindowTest.java @@ -1,5 +1,6 @@ package bridge; +import bridge.constant.BridgeMapElement; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.*; diff --git a/src/test/java/bridge/InputValidatorTest.java b/src/test/java/bridge/InputValidatorTest.java index b57d63bd0bd..e4423d30991 100644 --- a/src/test/java/bridge/InputValidatorTest.java +++ b/src/test/java/bridge/InputValidatorTest.java @@ -1,5 +1,6 @@ package bridge; +import bridge.view.InputValidator; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.*; From bc3b328d2295a6cf16722f3fed013e90f40d3e68 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 00:41:38 +0900 Subject: [PATCH 64/73] =?UTF-8?q?refactor:=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/constant/GameResult.java | 7 +------ src/main/java/bridge/model/BridgeStageRecord.java | 2 +- src/main/java/bridge/view/OutputView.java | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/java/bridge/constant/GameResult.java b/src/main/java/bridge/constant/GameResult.java index 221d21f7144..fc80841577a 100644 --- a/src/main/java/bridge/constant/GameResult.java +++ b/src/main/java/bridge/constant/GameResult.java @@ -14,13 +14,8 @@ public enum GameResult { this.message = message; } - @Override - public String toString() { - return message; - } - public static String gameResult(){ - if (BridgeStageRecord.isClearsGame()){ + if (BridgeStageRecord.clearsGame()){ return GAME_SUCCESS.message; } return GAME_FAILED.message; diff --git a/src/main/java/bridge/model/BridgeStageRecord.java b/src/main/java/bridge/model/BridgeStageRecord.java index 2b3dcd3c588..aa239a35ec0 100644 --- a/src/main/java/bridge/model/BridgeStageRecord.java +++ b/src/main/java/bridge/model/BridgeStageRecord.java @@ -38,7 +38,7 @@ public static boolean canNotMoveNextStage() { return !canMoveNextStage; } - public static boolean isClearsGame() { + public static boolean clearsGame() { return clearsGame; } diff --git a/src/main/java/bridge/view/OutputView.java b/src/main/java/bridge/view/OutputView.java index 70f15b5a35d..09dd31d175d 100644 --- a/src/main/java/bridge/view/OutputView.java +++ b/src/main/java/bridge/view/OutputView.java @@ -40,7 +40,7 @@ public void printErrorMessage(String errorMessage){ public void printGameStart() { System.out.println(GameProgressMessage.BRIDGE_GAME_START); - System.out.println(); + printEnter(); } public void printInputBridgeSize() { From 592f8de86502f81a279d39395cef15f6d51205de Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 12:38:08 +0900 Subject: [PATCH 65/73] =?UTF-8?q?test:=20Bridge=20=EA=B2=8C=EC=9E=84=20?= =?UTF-8?q?=EC=A7=84=ED=96=89=EC=9D=98=20=EA=B8=B0=EB=B3=B8=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=EA=B0=80=20true=EC=9D=B8=EC=A7=80=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/BridgeStageRecordTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/test/java/bridge/BridgeStageRecordTest.java diff --git a/src/test/java/bridge/BridgeStageRecordTest.java b/src/test/java/bridge/BridgeStageRecordTest.java new file mode 100644 index 00000000000..b505ffb2589 --- /dev/null +++ b/src/test/java/bridge/BridgeStageRecordTest.java @@ -0,0 +1,16 @@ +package bridge; + +import bridge.model.BridgeStageRecord; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.*; + +class BridgeStageRecordTest { + + @Test + @DisplayName("Bridge 게임 진행의 기본 상태가 true인지 확인한다. ") + void checkDefaultGameProcessing(){ + boolean isProcessing = BridgeStageRecord.isProgressing(); + assertThat(isProcessing).isTrue(); + } +} From 36b19167769f84baa481a06eee74964d68a9da44 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 12:39:49 +0900 Subject: [PATCH 66/73] =?UTF-8?q?test:=20Bridge=20=EA=B2=8C=EC=9E=84=20?= =?UTF-8?q?=EC=A7=84=ED=96=89=EC=9D=98=20=EA=B8=B0=EB=B3=B8=20stage?= =?UTF-8?q?=EA=B0=80=200=EC=9D=B8=EC=A7=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/BridgeStageRecordTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/test/java/bridge/BridgeStageRecordTest.java b/src/test/java/bridge/BridgeStageRecordTest.java index b505ffb2589..f6ea8482e2e 100644 --- a/src/test/java/bridge/BridgeStageRecordTest.java +++ b/src/test/java/bridge/BridgeStageRecordTest.java @@ -8,9 +8,16 @@ class BridgeStageRecordTest { @Test - @DisplayName("Bridge 게임 진행의 기본 상태가 true인지 확인한다. ") + @DisplayName("Bridge 게임 진행의 기본 상태가 true인지 확인한다.") void checkDefaultGameProcessing(){ boolean isProcessing = BridgeStageRecord.isProgressing(); assertThat(isProcessing).isTrue(); } + + @Test + @DisplayName("Bridge 게임 진행의 기본 stage가 0인지 확인한다.") + void checkDefaultGameStage(){ + int curStage = BridgeStageRecord.getCurStage(); + assertThat(curStage).isEqualTo(0); + } } From cc7a7ced087aef29abfdfe4de5609f7bd18d2900 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 12:47:23 +0900 Subject: [PATCH 67/73] =?UTF-8?q?test:=20bridge=EB=A5=BC=20=EC=99=84?= =?UTF-8?q?=EC=A3=BC=ED=96=88=EC=9D=84=20=EB=95=8C=20false=EB=A5=BC=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=ED=95=98=EB=8A=94=EC=A7=80=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/BridgeMakerTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/bridge/BridgeMakerTest.java b/src/test/java/bridge/BridgeMakerTest.java index ee1666e02e8..e447f487777 100644 --- a/src/test/java/bridge/BridgeMakerTest.java +++ b/src/test/java/bridge/BridgeMakerTest.java @@ -53,4 +53,19 @@ void checkBridgeStage(){ //then assertThat(stageStatus).isTrue(); } + + @Test + @DisplayName("bridge를 완주했을 때 false를 반환하는지 확인한다.") + void checkBridgeStatus(){ + //given + Bridge saveBridge = new Bridge(bridge); + + //when + boolean stageStatus = saveBridge.clearsAllStage(3, true); + + //then + assertThat(stageStatus).isFalse(); + } + + } From e6a82f49b2f73d6ce9bbe08214daa5c4d27f3203 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 13:00:07 +0900 Subject: [PATCH 68/73] =?UTF-8?q?test:=20Bridge=20=EA=B2=8C=EC=9E=84?= =?UTF-8?q?=EC=9D=98=20=EB=8B=A4=EC=9D=8C=20=EB=8B=A8=EA=B3=84=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EC=8B=9C=20stage=EA=B0=80=201=20=EC=A6=9D?= =?UTF-8?q?=EA=B0=80=ED=95=98=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/model/BridgeGame.java | 2 +- src/test/java/bridge/BridgeStageRecordTest.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/bridge/model/BridgeGame.java b/src/main/java/bridge/model/BridgeGame.java index fc208920f6b..901823def4f 100644 --- a/src/main/java/bridge/model/BridgeGame.java +++ b/src/main/java/bridge/model/BridgeGame.java @@ -48,7 +48,7 @@ public void retry(String bridgeRetryCommand) { } } - public void checkStageStatus(boolean canMoveStage){ + private void checkStageStatus(boolean canMoveStage){ if (bridge.clearsAllStage(BridgeStageRecord.getCurStage(), canMoveStage)) { BridgeStageRecord.changeProgressStatus(CLEARS_GAME); } diff --git a/src/test/java/bridge/BridgeStageRecordTest.java b/src/test/java/bridge/BridgeStageRecordTest.java index f6ea8482e2e..1cf33f1ce84 100644 --- a/src/test/java/bridge/BridgeStageRecordTest.java +++ b/src/test/java/bridge/BridgeStageRecordTest.java @@ -20,4 +20,16 @@ void checkDefaultGameStage(){ int curStage = BridgeStageRecord.getCurStage(); assertThat(curStage).isEqualTo(0); } + + @Test + @DisplayName("Bridge 게임의 다음 단계로 이동 시 stage가 1 증가하는지 확인한다.") + void checkNextGameStage(){ + BridgeStageRecord.nextStage(); + + int curStage = BridgeStageRecord.getCurStage(); + + assertThat(curStage).isEqualTo(1); + } + + } From e385dcc31aef655630b929c2939314656b859ada Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 13:00:37 +0900 Subject: [PATCH 69/73] =?UTF-8?q?test:=20Bridge=20=EA=B2=8C=EC=9E=84?= =?UTF-8?q?=EC=9D=98=20=EC=83=81=ED=83=9C=EA=B0=80=20=EC=9D=B4=EB=8F=99?= =?UTF-8?q?=ED=95=A0=20=EC=88=98=20=EC=97=86=EC=9D=84=20=EB=95=8C=20Record?= =?UTF-8?q?=EC=97=90=20=EC=A0=80=EC=9E=A5=EB=90=98=EB=8A=94=EC=A7=80=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/BridgeStageRecordTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/java/bridge/BridgeStageRecordTest.java b/src/test/java/bridge/BridgeStageRecordTest.java index 1cf33f1ce84..5c2f0b002c5 100644 --- a/src/test/java/bridge/BridgeStageRecordTest.java +++ b/src/test/java/bridge/BridgeStageRecordTest.java @@ -31,5 +31,13 @@ void checkNextGameStage(){ assertThat(curStage).isEqualTo(1); } + @Test + @DisplayName("Bridge 게임의 상태가 이동할 수 없을 때 Record에 저장되는지 확인한다.") + void checkNextGameStatus(){ + BridgeStageRecord.changeMoveStatus(false); + + boolean canNotMoveNextStage = BridgeStageRecord.canNotMoveNextStage(); + assertThat(canNotMoveNextStage).isTrue(); + } } From 6b25e9689c31cd8b3c72ab94f21e26a87fc6bc95 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 13:03:54 +0900 Subject: [PATCH 70/73] =?UTF-8?q?test:=20Bridge=20=EA=B2=8C=EC=9E=84?= =?UTF-8?q?=EC=9D=B4=20=EC=99=84=EC=A3=BC=EB=90=98=EC=97=88=EC=9D=84=20?= =?UTF-8?q?=EB=95=8C=20Record=EC=97=90=20=EC=A0=80=EC=9E=A5=EB=90=98?= =?UTF-8?q?=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/BridgeStageRecordTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/bridge/BridgeStageRecordTest.java b/src/test/java/bridge/BridgeStageRecordTest.java index 5c2f0b002c5..4a62f43c31d 100644 --- a/src/test/java/bridge/BridgeStageRecordTest.java +++ b/src/test/java/bridge/BridgeStageRecordTest.java @@ -40,4 +40,14 @@ void checkNextGameStatus(){ assertThat(canNotMoveNextStage).isTrue(); } + + @Test + @DisplayName("Bridge 게임이 완주되었을 때 Record에 저장되는지 확인한다.") + void checkClearGameStatus(){ + BridgeStageRecord.changeProgressStatus(true); + + boolean canNotMoveNextStage = BridgeStageRecord.isProgressing(); + + assertThat(canNotMoveNextStage).isFalse(); + } } From a3229f188467c402225566d4485dd27f25bb4e90 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 13:46:18 +0900 Subject: [PATCH 71/73] =?UTF-8?q?refactor:=20=EC=A0=84=EC=B2=B4=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/bridge/BridgeGameTest.java | 1 - .../java/bridge/BridgeStageRecordTest.java | 53 ------------------- 2 files changed, 54 deletions(-) delete mode 100644 src/test/java/bridge/BridgeStageRecordTest.java diff --git a/src/test/java/bridge/BridgeGameTest.java b/src/test/java/bridge/BridgeGameTest.java index b5229df18d1..6e95e9dccf8 100644 --- a/src/test/java/bridge/BridgeGameTest.java +++ b/src/test/java/bridge/BridgeGameTest.java @@ -15,7 +15,6 @@ class BridgeGameTest { void checkBridgeStageRecordReset(){ //given bridgeGame.retry("R"); - BridgeStageRecord.reset(); //when boolean canNotMoveNextStage = BridgeStageRecord.canNotMoveNextStage(); diff --git a/src/test/java/bridge/BridgeStageRecordTest.java b/src/test/java/bridge/BridgeStageRecordTest.java deleted file mode 100644 index 4a62f43c31d..00000000000 --- a/src/test/java/bridge/BridgeStageRecordTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package bridge; - -import bridge.model.BridgeStageRecord; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import static org.assertj.core.api.Assertions.*; - -class BridgeStageRecordTest { - - @Test - @DisplayName("Bridge 게임 진행의 기본 상태가 true인지 확인한다.") - void checkDefaultGameProcessing(){ - boolean isProcessing = BridgeStageRecord.isProgressing(); - assertThat(isProcessing).isTrue(); - } - - @Test - @DisplayName("Bridge 게임 진행의 기본 stage가 0인지 확인한다.") - void checkDefaultGameStage(){ - int curStage = BridgeStageRecord.getCurStage(); - assertThat(curStage).isEqualTo(0); - } - - @Test - @DisplayName("Bridge 게임의 다음 단계로 이동 시 stage가 1 증가하는지 확인한다.") - void checkNextGameStage(){ - BridgeStageRecord.nextStage(); - - int curStage = BridgeStageRecord.getCurStage(); - - assertThat(curStage).isEqualTo(1); - } - - @Test - @DisplayName("Bridge 게임의 상태가 이동할 수 없을 때 Record에 저장되는지 확인한다.") - void checkNextGameStatus(){ - BridgeStageRecord.changeMoveStatus(false); - - boolean canNotMoveNextStage = BridgeStageRecord.canNotMoveNextStage(); - - assertThat(canNotMoveNextStage).isTrue(); - } - - @Test - @DisplayName("Bridge 게임이 완주되었을 때 Record에 저장되는지 확인한다.") - void checkClearGameStatus(){ - BridgeStageRecord.changeProgressStatus(true); - - boolean canNotMoveNextStage = BridgeStageRecord.isProgressing(); - - assertThat(canNotMoveNextStage).isFalse(); - } -} From 5e5a703684d184a827bf40557bffb6c33e340c56 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 14:09:34 +0900 Subject: [PATCH 72/73] =?UTF-8?q?test:=20=EA=B2=8C=EC=9E=84=20=EA=B2=B0?= =?UTF-8?q?=EA=B3=BC=20=EB=A9=94=EC=8B=9C=EC=A7=80=EB=A5=BC=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=ED=95=98=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/bridge/constant/GameResult.java | 5 +++++ src/test/java/bridge/BridgeWindowTest.java | 6 +++--- src/test/java/bridge/GameResultTest.java | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 src/test/java/bridge/GameResultTest.java diff --git a/src/main/java/bridge/constant/GameResult.java b/src/main/java/bridge/constant/GameResult.java index fc80841577a..66872079b5c 100644 --- a/src/main/java/bridge/constant/GameResult.java +++ b/src/main/java/bridge/constant/GameResult.java @@ -20,4 +20,9 @@ public static String gameResult(){ } return GAME_FAILED.message; } + + @Override + public String toString() { + return message; + } } diff --git a/src/test/java/bridge/BridgeWindowTest.java b/src/test/java/bridge/BridgeWindowTest.java index 7e98a431424..f926d709074 100644 --- a/src/test/java/bridge/BridgeWindowTest.java +++ b/src/test/java/bridge/BridgeWindowTest.java @@ -7,10 +7,10 @@ class BridgeWindowTest { @Test - @DisplayName("입력한 칸이 성공했을 때 SUCCESS를 반환하는지 확인한다.") + @DisplayName("입력한 칸이 실패했을 때 FAIL을 반환하는지 확인한다.") void getBridgeWindowElement(){ - BridgeMapElement bridgeWindowElement = BridgeMapElement.getStageWindowElement(true); - assertThat(bridgeWindowElement).isEqualTo(BridgeMapElement.SUCCESS); + BridgeMapElement bridgeWindowElement = BridgeMapElement.getStageWindowElement(false); + assertThat(bridgeWindowElement).isEqualTo(BridgeMapElement.FAIL); } } diff --git a/src/test/java/bridge/GameResultTest.java b/src/test/java/bridge/GameResultTest.java new file mode 100644 index 00000000000..26149d79391 --- /dev/null +++ b/src/test/java/bridge/GameResultTest.java @@ -0,0 +1,17 @@ +package bridge; + +import bridge.constant.GameResult; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class GameResultTest { + + @Test + @DisplayName("게임 결과 메시지를 반환하는지 확인한다.") + void getBridgeGameResult(){ + String gameResult = GameResult.gameResult(); + assertThat(gameResult).isEqualTo(GameResult.GAME_FAILED.toString()); + } +} From 6a7a5c90c2ac592bc5702d7b19cd7a0eb2925b57 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Sat, 26 Aug 2023 14:11:09 +0900 Subject: [PATCH 73/73] =?UTF-8?q?docs:=20README.md=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 80 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 21 deletions(-) diff --git a/docs/README.md b/docs/README.md index 6aa976df68e..ab4c1bb2fb6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,29 +1,67 @@ ## 기능 목록 -- input -1. 다리 길이를 입력 받는다. - - 3~20 사이의 숫자이다. -2. 이동할 칸을 입력 받는다. - - 위 칸 -> U, 아래 칸 -> D -3. 재시작 여부를 입력 받는다. +### input +- [x] 다리 길이를 입력 받는다. + - 3~20 사이의 숫자이다. +- [x] 이동할 칸을 입력 받는다. + - 위 칸 -> U, 아래 칸 -> D +- [x] 재시작 여부를 입력 받는다. - 재시작 -> R, 종료 -> Q -- output -1. 다리 화면 출력 - - 이동한 칸을 건널 수 있다면 -> O 건널 수 없다면 X +### inputValidator +- [x] 다리 길이 validate + - 숫자이다. + - 3~20사이의 숫자이다. +- [x] 이동할 칸 validate + - 대문자 영어이다. + - U or D이다. +- [x] 재시작 validate + - 대문자 영어이다. + - R or Q이다. -- bridge -1. 다리 길이 만큼 다리를 생성한다. - - List 위 칸 -> U, 아래 칸 -> D - - 랜덤 숫자 1 -> 위 칸, 0 -> 아래 칸 -2. 이동 했을 때 성공/실패를 비교한다. -3. 다리의 상태에 대한 화면을 생성한다. -4. 재시작해도 처음에 만든 다리로 재사용한다. +### output +1. 다리 화면 출력한다. +- [x] 이동한 칸을 건널 수 있다면 -> O 건널 수 없다면 X +- [x] 결과 출력한다. +- [x] 에러 출력한다. +- [x] 진행 메시지 출력한다. + +### bridge +1. 다리 길이 만큼 다리를 저장한다. +- [x] List 위 칸 -> U, 아래 칸 -> D + - 재시작해도 처음에 만든 다리로 재사용한다. + +### BridgeMaker +- [x] 다리를 만든다. + - 랜덤 숫자 1 -> 위 칸, 0 -> 아래 칸 + +### BridgeMap +- [x] 게임 화면을 만든다. + +### BridgeStageRecord +- [x] 게임 진행 결과를 기록한다. + +## 상수 처리 + +### BridgeMapElement +-[x] 게임 화면 요소 + +### ErrorMessage +-[x] 에러 메시지 + +### GameCommand +-[x] 게임 명령어 + +### GameProgressMessage +-[x] 게임 진행 메시지 + +### GameResult +-[x] 게임 결정 ## 에러 처리 -- 에러 발생시 [ERROR] 단어가 포함 되어있어야 한다. -- 그 부분 부터 다시 입력 받는다. +- [x] 에러 발생시 [ERROR] 단어가 포함 되어있어야 한다. +- [x] 그 부분 부터 다시 입력 받는다. -1. 다리 길이는 3~20 사이의 숫자이다. -2. 이동할 칸 명령어는 'U', 'D' 이다. -3. 재시작 여부 명령어는 'R', 'Q' 이다. \ No newline at end of file +- [x] 다리 길이는 3~20 사이의 숫자이다. +- [x] 이동할 칸 명령어는 'U', 'D' 이다. +- [x] 재시작 여부 명령어는 'R', 'Q' 이다. \ No newline at end of file