From ee978791d93b88e1f982a28e2d27fe4f8f9fe0fa Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 15:57:21 +0900 Subject: [PATCH 01/41] =?UTF-8?q?docs:=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/Readme.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 docs/Readme.md diff --git a/docs/Readme.md b/docs/Readme.md new file mode 100644 index 0000000000..70ff132998 --- /dev/null +++ b/docs/Readme.md @@ -0,0 +1,25 @@ +## 기능 구현 +- Car + - 각 자동차에 이름을 부여할 수 있다. 전진하는 자동차를 출력할 때 자동차 이름을 같이 출력한다. + - 자동차 이름은 쉼표(,)를 기준으로 구분하며 이름은 5자 이하만 가능하다. + - 자동차의 개수는 2대 이상 + +- Cars + - 주어진 횟수 동안 n대의 자동차는 전진 또는 멈출 수 있다. + +- InputView + - 경주 할 자동차 이름을 입력한다(이름은 쉼표(,) 기준으로 구분) + - 사용자는 몇 번의 이동을 할 것인지를 입력한다. + +- AdvanceCondition + - 전진하는 조건은 0에서 9 사이에서 무작위 값을 구한 후 무작위 값이 4 이상일 경우이다. + +- OutputView + - 실행 결과 출력 + - 자동차 경주 게임을 완료한 후 누가 우승했는지를 알려준다. 우승자는 한 명 이상일 수 있다. + - 우승자가 여러 명일 경우 쉼표(,)를 이용하여 구분한다. + +- InputValidator + - 사용자가 잘못된 값을 입력할 경우 IllegalArgumentException를 발생시키고, + - "[ERROR]"로 시작하는 에러 메시지를 출력 후 그 부분부터 입력을 다시 받는다. + - 쉼표로 구분 \ No newline at end of file From d6736be231f41a9800466addb2efc2f7d6ac6483 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 16:56:00 +0900 Subject: [PATCH 02/41] =?UTF-8?q?feat:=20InputView=20readCarNames=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/racingcar/InputView.java | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/racingcar/InputView.java diff --git a/src/main/java/racingcar/InputView.java b/src/main/java/racingcar/InputView.java new file mode 100644 index 0000000000..ac7ba7c060 --- /dev/null +++ b/src/main/java/racingcar/InputView.java @@ -0,0 +1,32 @@ +package racingcar; + +import java.util.Scanner; +import java.util.function.Supplier; + +public class InputView { + + private final OutputView outputView = new OutputView(); + public final InputValidator inputValidator = new InputValidator(); + private final Scanner scan = new Scanner(System.in); + + public Cars readCarNames(){ + return read(() -> { + outputView.printInputCarNames(); + String names = scan.next(); + inputValidator.validateContainDivision(names); + Cars cars = new Cars(); + cars.addCars(names); + return cars; + }); + } + + private T read(Supplier supplier){ + while (true){ + try{ + return supplier.get(); + }catch (IllegalArgumentException e){ + outputView.printErrorMessage(e.getMessage()); + } + } + } +} From e40863f0794569997a195ef99e4d4a23d1b08fb5 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 16:56:12 +0900 Subject: [PATCH 03/41] =?UTF-8?q?feat:=20OutputView=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/racingcar/OutputView.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/racingcar/OutputView.java diff --git a/src/main/java/racingcar/OutputView.java b/src/main/java/racingcar/OutputView.java new file mode 100644 index 0000000000..8c567ace90 --- /dev/null +++ b/src/main/java/racingcar/OutputView.java @@ -0,0 +1,11 @@ +package racingcar; + +public class OutputView { + public void printErrorMessage(String message) { + System.out.println(message); + } + + public void printInputCarNames(){ + System.out.println(ProgressMessage.INPUT_CAR_NAMES); + } +} From 6be50c54fff90462e3c962b910d95f5a238a54a5 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 16:56:28 +0900 Subject: [PATCH 04/41] =?UTF-8?q?feat:=20ProgressMessage=20INPUT=5FCAR=5FN?= =?UTF-8?q?AMES=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/racingcar/ProgressMessage.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/racingcar/ProgressMessage.java diff --git a/src/main/java/racingcar/ProgressMessage.java b/src/main/java/racingcar/ProgressMessage.java new file mode 100644 index 0000000000..5f5614f3ae --- /dev/null +++ b/src/main/java/racingcar/ProgressMessage.java @@ -0,0 +1,17 @@ +package racingcar; + +public enum ProgressMessage { + + INPUT_CAR_NAMES("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)"); + + private final String message; + + ProgressMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + return message; + } +} From 579574fa5188f8a3bbd5dc61c32106f57c4a3e1f Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 16:56:37 +0900 Subject: [PATCH 05/41] =?UTF-8?q?feat:=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/racingcar/ErrorMessage.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/racingcar/ErrorMessage.java diff --git a/src/main/java/racingcar/ErrorMessage.java b/src/main/java/racingcar/ErrorMessage.java new file mode 100644 index 0000000000..f53c63ee61 --- /dev/null +++ b/src/main/java/racingcar/ErrorMessage.java @@ -0,0 +1,18 @@ +package racingcar; + +public enum ErrorMessage { + NAME_DIVISION_ERROR("이름은 쉼표(,) 기준으로 구분합니다."), + NAME_LENGTH_ERROR("자동차 이름이름은 5자 이하만 가능합니다."); + + private static final String ERROR = "[ERROR]"; + private final String message; + + ErrorMessage(String message) { + this.message = message; + } + + public String getMessage() { + return ERROR + message; + } + +} From 1f32e203aeda42f9469b3f9a8ee91d250db05057 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 16:56:45 +0900 Subject: [PATCH 06/41] =?UTF-8?q?feat:=20InputValidator=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/racingcar/InputValidator.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/racingcar/InputValidator.java diff --git a/src/main/java/racingcar/InputValidator.java b/src/main/java/racingcar/InputValidator.java new file mode 100644 index 0000000000..be22d6dba5 --- /dev/null +++ b/src/main/java/racingcar/InputValidator.java @@ -0,0 +1,19 @@ +package racingcar; + +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; + +public class InputValidator { + + private static final int MIN_NAME_SIZE = 2; + private static final String DIVISION = ","; + + public void validateContainDivision(String name) { + Set carNames = Arrays.stream(name.split(DIVISION)).collect(Collectors.toSet()); + if(carNames.size() < MIN_NAME_SIZE){ + throw new IllegalArgumentException(ErrorMessage.NAME_DIVISION_ERROR.getMessage()); + } + } + +} From fcffeb032908f35796d963a96dab27f636c690e5 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 16:57:33 +0900 Subject: [PATCH 07/41] =?UTF-8?q?test:=20=EC=89=BC=ED=91=9C=EB=A5=BC=20?= =?UTF-8?q?=ED=8F=AC=ED=95=A8=ED=95=98=EC=97=AC=20=EC=9E=85=EB=A0=A5?= =?UTF-8?q?=EA=B0=92=EC=9D=84=202=EB=AA=85=EC=9D=B4=EC=83=81=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=ED=95=98=EC=A7=80=20=EC=95=8A=EC=95=98=EC=9D=84=20?= =?UTF-8?q?=EB=95=8C=20=EC=97=90=EB=9F=AC=EA=B0=80=20=EB=B0=9C=EC=83=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/racingcar/InputValidatorTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/java/racingcar/InputValidatorTest.java diff --git a/src/test/java/racingcar/InputValidatorTest.java b/src/test/java/racingcar/InputValidatorTest.java new file mode 100644 index 0000000000..a7627d7b82 --- /dev/null +++ b/src/test/java/racingcar/InputValidatorTest.java @@ -0,0 +1,21 @@ +package racingcar; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.*; + +class InputValidatorTest { + + private static final String ERROR = "[ERROR]"; + + @Test + @DisplayName("쉼표를 포함하여 입력값을 2명이상 입력했는지 확인한다.") + void inputContainDivision(){ + InputValidator inputValidator = new InputValidator(); + assertThatThrownBy(() -> inputValidator.validateContainDivision("pobi,")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(ERROR); + + } + +} From 13501c907ddb6d79377cb5c51ef14fe5d80fd283 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 17:01:13 +0900 Subject: [PATCH 08/41] =?UTF-8?q?test:=20=EC=9E=90=EB=8F=99=EC=B0=A8=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=EC=9D=B4=205=EC=9E=90=EB=A5=BC=20=EC=B4=88?= =?UTF-8?q?=EA=B3=BC=ED=95=98=EB=A9=B4=20=EC=97=90=EB=9F=AC=EA=B0=80=20?= =?UTF-8?q?=EB=B0=9C=EC=83=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/racingcar/InputValidatorTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/test/java/racingcar/InputValidatorTest.java b/src/test/java/racingcar/InputValidatorTest.java index a7627d7b82..bb299c267d 100644 --- a/src/test/java/racingcar/InputValidatorTest.java +++ b/src/test/java/racingcar/InputValidatorTest.java @@ -9,13 +9,19 @@ class InputValidatorTest { private static final String ERROR = "[ERROR]"; @Test - @DisplayName("쉼표를 포함하여 입력값을 2명이상 입력했는지 확인한다.") + @DisplayName("쉼표를 포함하여 입력값을 2명이상 입력하지 않았을 때 에러가 발생한다.") void inputContainDivision(){ InputValidator inputValidator = new InputValidator(); assertThatThrownBy(() -> inputValidator.validateContainDivision("pobi,")) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining(ERROR); - } + @Test + @DisplayName("자동차 이름이 5자를 초과하면 에러가 발생한다.") + void inputCarNamesLength(){ + assertThatThrownBy(() -> new Car("junsu12")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(ERROR); + } } From 862c68328d363c3419f8e2817d8e0a4ee075800b Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 17:07:22 +0900 Subject: [PATCH 09/41] =?UTF-8?q?feat:=20Car=20validateCarNameLength=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/racingcar/Car.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/racingcar/Car.java b/src/main/java/racingcar/Car.java index ab3df94921..8ee31b75db 100644 --- a/src/main/java/racingcar/Car.java +++ b/src/main/java/racingcar/Car.java @@ -1,12 +1,19 @@ package racingcar; public class Car { + private static final int MAX_NAME_LENGTH = 5; private final String name; private int position = 0; public Car(String name) { + validateCarNameLength(name); this.name = name; } // 추가 기능 구현 + public void validateCarNameLength(String name){ + if (name.length() > MAX_NAME_LENGTH){ + throw new IllegalArgumentException(ErrorMessage.NAME_LENGTH_ERROR.getMessage()); + } + } } From da9476f0962b2f594d4ba141b4370cf850fb7661 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 17:07:44 +0900 Subject: [PATCH 10/41] =?UTF-8?q?feat:=20Cars=20addCars=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/racingcar/Cars.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/racingcar/Cars.java diff --git a/src/main/java/racingcar/Cars.java b/src/main/java/racingcar/Cars.java new file mode 100644 index 0000000000..f7ba98b743 --- /dev/null +++ b/src/main/java/racingcar/Cars.java @@ -0,0 +1,17 @@ +package racingcar; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +public class Cars { + private static final String DIVISION = ","; + private final List cars = new ArrayList<>(); + + public void addCars(String name){ + Set carNames = Arrays.stream(name.split(DIVISION)).collect(Collectors.toSet()); + carNames.stream().map(Car::new).forEach(cars::add); + } +} From bed56430383e7d30d657325de6519dc0cd3fc470 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 19:32:00 +0900 Subject: [PATCH 11/41] =?UTF-8?q?feat:=20InputView=20readTryCount=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/racingcar/InputView.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/racingcar/InputView.java b/src/main/java/racingcar/InputView.java index ac7ba7c060..fd7117697e 100644 --- a/src/main/java/racingcar/InputView.java +++ b/src/main/java/racingcar/InputView.java @@ -20,6 +20,15 @@ public Cars readCarNames(){ }); } + public int readTryCount(){ + return read(() ->{ + outputView.printInputTryCount(); + int count = scan.nextInt(); + inputValidator.validateTryCount(count); + return count; + }); + } + private T read(Supplier supplier){ while (true){ try{ From 6e1db51b26cd377a27073d1713e249d4a2dca9c2 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 19:32:12 +0900 Subject: [PATCH 12/41] =?UTF-8?q?feat:=20InputValidator=20validateTryCount?= =?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/racingcar/InputValidator.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/racingcar/InputValidator.java b/src/main/java/racingcar/InputValidator.java index be22d6dba5..f35d8d25b7 100644 --- a/src/main/java/racingcar/InputValidator.java +++ b/src/main/java/racingcar/InputValidator.java @@ -6,6 +6,7 @@ public class InputValidator { + private static final int MIN_TRY_COUNT = 1; private static final int MIN_NAME_SIZE = 2; private static final String DIVISION = ","; @@ -16,4 +17,9 @@ public void validateContainDivision(String name) { } } + public void validateTryCount(int count) { + if (count < MIN_TRY_COUNT){ + throw new IllegalArgumentException(ErrorMessage.TRY_COUNT_ERROR.getMessage()); + } + } } From 9d52a2d2545a2383cbd23ea769c26685f25d37e5 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 19:32:35 +0900 Subject: [PATCH 13/41] =?UTF-8?q?feat:=20ErrorMessage=20TRY=5FCOUNT=5FERRO?= =?UTF-8?q?R=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/racingcar/ErrorMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/racingcar/ErrorMessage.java b/src/main/java/racingcar/ErrorMessage.java index f53c63ee61..ff46717438 100644 --- a/src/main/java/racingcar/ErrorMessage.java +++ b/src/main/java/racingcar/ErrorMessage.java @@ -2,7 +2,8 @@ public enum ErrorMessage { NAME_DIVISION_ERROR("이름은 쉼표(,) 기준으로 구분합니다."), - NAME_LENGTH_ERROR("자동차 이름이름은 5자 이하만 가능합니다."); + NAME_LENGTH_ERROR("자동차 이름이름은 5자 이하만 가능합니다."), + TRY_COUNT_ERROR("시도할 회수는 1회 이상입니다."); private static final String ERROR = "[ERROR]"; private final String message; From 3577d1d4885961226c5419bc5fc19350719c0ab3 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 19:32:45 +0900 Subject: [PATCH 14/41] =?UTF-8?q?feat:=20ProgressMessage=20INPUT=5FTRY=5FC?= =?UTF-8?q?OUNT=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/racingcar/ProgressMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/racingcar/ProgressMessage.java b/src/main/java/racingcar/ProgressMessage.java index 5f5614f3ae..99f31fb401 100644 --- a/src/main/java/racingcar/ProgressMessage.java +++ b/src/main/java/racingcar/ProgressMessage.java @@ -2,7 +2,8 @@ public enum ProgressMessage { - INPUT_CAR_NAMES("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)"); + INPUT_CAR_NAMES("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)"), + INPUT_TRY_COUNT("시도할 회수는 몇회인가요?"); private final String message; From 1f941ea75c5975b9d352d4d6d36420973b216d9c Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 19:32:57 +0900 Subject: [PATCH 15/41] =?UTF-8?q?feat:=20OutputView=20printInputTryCount?= =?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/racingcar/OutputView.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/racingcar/OutputView.java b/src/main/java/racingcar/OutputView.java index 8c567ace90..f2586ceea4 100644 --- a/src/main/java/racingcar/OutputView.java +++ b/src/main/java/racingcar/OutputView.java @@ -8,4 +8,8 @@ public void printErrorMessage(String message) { public void printInputCarNames(){ System.out.println(ProgressMessage.INPUT_CAR_NAMES); } + + public void printInputTryCount(){ + System.out.println(ProgressMessage.INPUT_TRY_COUNT); + } } From 1ee97d48bf64e140bcb3d8b73b4a844ff891ac10 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 19:33:15 +0900 Subject: [PATCH 16/41] =?UTF-8?q?test:=20=EC=8B=9C=EB=8F=84=ED=95=A0=20?= =?UTF-8?q?=ED=9A=9F=EC=88=98=EA=B0=80=201=ED=9A=8C=20=EC=9D=B4=EC=83=81?= =?UTF-8?q?=EC=9D=B4=20=EC=95=84=EB=8B=88=EB=9D=BC=EB=A9=B4=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=EA=B0=80=20=EB=B0=9C=EC=83=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/racingcar/InputValidatorTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/test/java/racingcar/InputValidatorTest.java b/src/test/java/racingcar/InputValidatorTest.java index bb299c267d..185de5fabf 100644 --- a/src/test/java/racingcar/InputValidatorTest.java +++ b/src/test/java/racingcar/InputValidatorTest.java @@ -7,11 +7,11 @@ class InputValidatorTest { private static final String ERROR = "[ERROR]"; + InputValidator inputValidator = new InputValidator(); @Test @DisplayName("쉼표를 포함하여 입력값을 2명이상 입력하지 않았을 때 에러가 발생한다.") void inputContainDivision(){ - InputValidator inputValidator = new InputValidator(); assertThatThrownBy(() -> inputValidator.validateContainDivision("pobi,")) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining(ERROR); @@ -24,4 +24,12 @@ void inputCarNamesLength(){ .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining(ERROR); } + + @Test + @DisplayName("시도할 횟수가 1회 이상이 아니라면 에러가 발생한다.") + void inputTryCount(){ + assertThatThrownBy(() -> inputValidator.validateTryCount(0)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(ERROR); + } } From b1ef153c61bf4e087099450874d72c3638560b3e Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 20:00:52 +0900 Subject: [PATCH 17/41] =?UTF-8?q?feat:=20CreateRandomValue=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/racingcar/CreateRandomValue.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/java/racingcar/CreateRandomValue.java diff --git a/src/main/java/racingcar/CreateRandomValue.java b/src/main/java/racingcar/CreateRandomValue.java new file mode 100644 index 0000000000..717332049a --- /dev/null +++ b/src/main/java/racingcar/CreateRandomValue.java @@ -0,0 +1,15 @@ +package racingcar; + + +import java.util.Random; + +public class CreateRandomValue { + + private static final int MAX_RANDOM_NUMBER = 10; + private static final int MIN_RANDOM_VALUE = 4; + private static final Random random = new Random(); + public static boolean canMoveCar() { + int randomNumber = random.nextInt(MAX_RANDOM_NUMBER); + return randomNumber >= MIN_RANDOM_VALUE; + } +} \ No newline at end of file From 298f03f22e2ed26c55008b06b5ad8ddc3c504bdf Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 20:01:23 +0900 Subject: [PATCH 18/41] =?UTF-8?q?feat:=20RacingCarService=20moveCars=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/racingcar/RacingCarService.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/racingcar/RacingCarService.java diff --git a/src/main/java/racingcar/RacingCarService.java b/src/main/java/racingcar/RacingCarService.java new file mode 100644 index 0000000000..99caa012e0 --- /dev/null +++ b/src/main/java/racingcar/RacingCarService.java @@ -0,0 +1,8 @@ +package racingcar; + +public class RacingCarService { + + public void moveCars(Cars cars, int count){ + cars.moveCars(count); + } +} From aa28507f0c2e3bea6063a01f3e09c5c1702fe33d Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 20:01:36 +0900 Subject: [PATCH 19/41] =?UTF-8?q?feat:=20Car=20movePosition=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/racingcar/Car.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/racingcar/Car.java b/src/main/java/racingcar/Car.java index 8ee31b75db..05e02d89be 100644 --- a/src/main/java/racingcar/Car.java +++ b/src/main/java/racingcar/Car.java @@ -16,4 +16,8 @@ public void validateCarNameLength(String name){ throw new IllegalArgumentException(ErrorMessage.NAME_LENGTH_ERROR.getMessage()); } } + + public void movePosition(){ + position++; + } } From 70da97e7faa4c71a8dd0eeecc4aa3478232ed83b Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 20:01:49 +0900 Subject: [PATCH 20/41] =?UTF-8?q?feat:=20Cars=20moveCars=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/racingcar/Cars.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/racingcar/Cars.java b/src/main/java/racingcar/Cars.java index f7ba98b743..45638197ff 100644 --- a/src/main/java/racingcar/Cars.java +++ b/src/main/java/racingcar/Cars.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import java.util.stream.IntStream; public class Cars { private static final String DIVISION = ","; @@ -14,4 +15,14 @@ public void addCars(String name){ Set carNames = Arrays.stream(name.split(DIVISION)).collect(Collectors.toSet()); carNames.stream().map(Car::new).forEach(cars::add); } + + public void moveCars(int count){ + IntStream.range(0, count) + .forEach(i -> cars.forEach(car -> { + if (CreateRandomValue.canMoveCar()){ + car.movePosition(); + } + })); + } + } From ca64fe3f012e83c6300aa702b3d70f32d19ddfc8 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 20:37:44 +0900 Subject: [PATCH 21/41] =?UTF-8?q?feat:=20Car=20makeScreen=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/racingcar/Car.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/racingcar/Car.java b/src/main/java/racingcar/Car.java index 05e02d89be..12477f3edc 100644 --- a/src/main/java/racingcar/Car.java +++ b/src/main/java/racingcar/Car.java @@ -20,4 +20,13 @@ public void validateCarNameLength(String name){ public void movePosition(){ position++; } + + public StringBuilder makeScreen(StringBuilder stringBuilder) { + stringBuilder.append(name).append(" : "); + for (int i = 0; i < position; i++){ + stringBuilder.append("-"); + } + stringBuilder.append("\n"); + return stringBuilder; + } } From 7620eaf678d3843c84466cc50934d31fbf27de7a Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 20:38:01 +0900 Subject: [PATCH 22/41] =?UTF-8?q?feat:=20Cars=20executionResult=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/racingcar/Cars.java | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/racingcar/Cars.java b/src/main/java/racingcar/Cars.java index 45638197ff..20c598813a 100644 --- a/src/main/java/racingcar/Cars.java +++ b/src/main/java/racingcar/Cars.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import java.util.stream.IntStream; public class Cars { private static final String DIVISION = ","; @@ -16,13 +15,20 @@ public void addCars(String name){ carNames.stream().map(Car::new).forEach(cars::add); } - public void moveCars(int count){ - IntStream.range(0, count) - .forEach(i -> cars.forEach(car -> { - if (CreateRandomValue.canMoveCar()){ - car.movePosition(); - } - })); + public void moveCars(){ + cars.forEach(car -> { + if (CreateRandomValue.canMoveCar()) { + car.movePosition(); + } + }); + } + + public String executionResult(){ + return cars.stream() + .map(car -> car.makeScreen(new StringBuilder())) + .reduce(new StringBuilder(), StringBuilder::append) + .toString(); + } } From a27c098df63ddfda613edc0121bb0ca50bec8ac7 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 20:38:38 +0900 Subject: [PATCH 23/41] =?UTF-8?q?feat:=20OutputView=20printExecuteResult?= =?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/racingcar/OutputView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/racingcar/OutputView.java b/src/main/java/racingcar/OutputView.java index f2586ceea4..387d01ad10 100644 --- a/src/main/java/racingcar/OutputView.java +++ b/src/main/java/racingcar/OutputView.java @@ -12,4 +12,10 @@ public void printInputCarNames(){ public void printInputTryCount(){ System.out.println(ProgressMessage.INPUT_TRY_COUNT); } + + public void printExecuteResult(){ + System.out.println(ProgressMessage.EXECUTE_RESULT); + } + + } From 185a1b16fa22fea148faf8126d0b227e72929d38 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 20:38:49 +0900 Subject: [PATCH 24/41] =?UTF-8?q?feat:=20OutputView=20printCarsStatus=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/racingcar/OutputView.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/racingcar/OutputView.java b/src/main/java/racingcar/OutputView.java index 387d01ad10..7716788107 100644 --- a/src/main/java/racingcar/OutputView.java +++ b/src/main/java/racingcar/OutputView.java @@ -17,5 +17,7 @@ public void printExecuteResult(){ System.out.println(ProgressMessage.EXECUTE_RESULT); } - + public void printCarsStatus(Cars cars){ + System.out.println(cars.executionResult()); + } } From d8d28fc7b09063e83d8ff9f8d8aa04a18cd13b07 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 20:39:00 +0900 Subject: [PATCH 25/41] =?UTF-8?q?feat:=20ProgressMessage=20EXECUTE=5FRESUL?= =?UTF-8?q?T=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/racingcar/ProgressMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/racingcar/ProgressMessage.java b/src/main/java/racingcar/ProgressMessage.java index 99f31fb401..89dddf9879 100644 --- a/src/main/java/racingcar/ProgressMessage.java +++ b/src/main/java/racingcar/ProgressMessage.java @@ -3,7 +3,8 @@ public enum ProgressMessage { INPUT_CAR_NAMES("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)"), - INPUT_TRY_COUNT("시도할 회수는 몇회인가요?"); + INPUT_TRY_COUNT("시도할 회수는 몇회인가요?"), + EXECUTE_RESULT("실행 결과"); private final String message; From e613effd58636f3b59d99975878d73560024dfc3 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 20:39:13 +0900 Subject: [PATCH 26/41] =?UTF-8?q?feat:=20RacingCarService=20moveCars=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/racingcar/RacingCarService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/racingcar/RacingCarService.java b/src/main/java/racingcar/RacingCarService.java index 99caa012e0..aaaf6b7b63 100644 --- a/src/main/java/racingcar/RacingCarService.java +++ b/src/main/java/racingcar/RacingCarService.java @@ -2,7 +2,7 @@ public class RacingCarService { - public void moveCars(Cars cars, int count){ - cars.moveCars(count); + public void moveCars(Cars cars){ + cars.moveCars(); } } From bf3ba33cb69d9e66f071179ef2dc4ff6cb29c2b6 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 20:39:30 +0900 Subject: [PATCH 27/41] =?UTF-8?q?feat:=20RacingCarController=20run=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 --- .../java/racingcar/RacingCarController.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/racingcar/RacingCarController.java diff --git a/src/main/java/racingcar/RacingCarController.java b/src/main/java/racingcar/RacingCarController.java new file mode 100644 index 0000000000..8fed81ec8a --- /dev/null +++ b/src/main/java/racingcar/RacingCarController.java @@ -0,0 +1,29 @@ +package racingcar; + +public class RacingCarController { + + private final InputView inputView; + private final OutputView outputView; + private final RacingCarService racingCarService; + + public RacingCarController() { + this.inputView = new InputView(); + this.outputView = new OutputView(); + this.racingCarService = new RacingCarService(); + } + + public void run(){ + Cars cars = inputView.readCarNames(); + int tryCount = inputView.readTryCount(); + + outputView.printExecuteResult(); + changeCarsStatus(cars, tryCount); + } + + private void changeCarsStatus(Cars cars, int tryCount) { + for (int i = 0; i < tryCount; i++){ + racingCarService.moveCars(cars); + outputView.printCarsStatus(cars); + } + } +} From a9e6db77105b77acbd83707d8364c90b455f5eb0 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 20:39:45 +0900 Subject: [PATCH 28/41] =?UTF-8?q?test:=20=EC=9E=90=EB=8F=99=EC=B0=A8?= =?UTF-8?q?=EB=A5=BC=20=EC=B6=94=EA=B0=80=ED=96=88=EC=9D=84=20=EB=95=8C=20?= =?UTF-8?q?=EC=B0=A8=EB=A5=BC=20=EC=9B=80=EC=A7=81=EC=9D=B4=EB=A9=B4=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=EA=B2=B0=EA=B3=BC=EC=97=90=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=EC=9D=B4=20=EB=82=98=ED=83=80=EB=82=9C=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/racingcar/CarsTest.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/test/java/racingcar/CarsTest.java diff --git a/src/test/java/racingcar/CarsTest.java b/src/test/java/racingcar/CarsTest.java new file mode 100644 index 0000000000..535e2107d7 --- /dev/null +++ b/src/test/java/racingcar/CarsTest.java @@ -0,0 +1,23 @@ +package racingcar; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.*; + +class CarsTest { + + Cars cars = new Cars(); + + @Test + @DisplayName("자동차를 추가했을 때 차를 움직이면 실행결과에 이름이 나타난다.") + void showCarScreen(){ + cars.addCars("pobi,woni,jun"); + cars.moveCars(); + + String screen = cars.executionResult(); + + assertThat(screen).containsOnlyOnce("pobi :"); + assertThat(screen).containsOnlyOnce("woni :"); + assertThat(screen).containsOnlyOnce("jun :"); + } +} From 527c15260ef46baac2cbfdce65bf45c3e81c9d04 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 21:13:35 +0900 Subject: [PATCH 29/41] =?UTF-8?q?feat:=20Car=20getter=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/racingcar/Car.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/racingcar/Car.java b/src/main/java/racingcar/Car.java index 12477f3edc..4ffcd79e89 100644 --- a/src/main/java/racingcar/Car.java +++ b/src/main/java/racingcar/Car.java @@ -29,4 +29,12 @@ public StringBuilder makeScreen(StringBuilder stringBuilder) { stringBuilder.append("\n"); return stringBuilder; } + + public int getPosition() { + return position; + } + + public String getName() { + return name; + } } From ac8c13e6b8c0d4b0b27551dedda34fdd474425ed Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 21:13:52 +0900 Subject: [PATCH 30/41] =?UTF-8?q?feat:=20Cars=20finalWinner=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/racingcar/Cars.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/racingcar/Cars.java b/src/main/java/racingcar/Cars.java index 20c598813a..d0937c1454 100644 --- a/src/main/java/racingcar/Cars.java +++ b/src/main/java/racingcar/Cars.java @@ -28,7 +28,29 @@ public String executionResult(){ .map(car -> car.makeScreen(new StringBuilder())) .reduce(new StringBuilder(), StringBuilder::append) .toString(); + } + + public String finalWinner(){ + List winCars = getWinCarNames(); + + if (winCars.size() > 1) { + return String.join(", ", winCars); + } + return winCars.get(0); + } + private List getWinCarNames() { + return cars.stream() + .filter(car -> car.getPosition() == maxPosition()) + .map(Car::getName) + .collect(Collectors.toList()); + } + + private int maxPosition(){ + return cars.stream() + .mapToInt(Car::getPosition) + .max() + .orElse(0); } } From a0402b09b137cec4c7e9ea0d23f7ccbb4b04de5d Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 21:14:01 +0900 Subject: [PATCH 31/41] =?UTF-8?q?feat:=20OutputView=20printFinalWinner=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/racingcar/OutputView.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/racingcar/OutputView.java b/src/main/java/racingcar/OutputView.java index 7716788107..0c02b0cae9 100644 --- a/src/main/java/racingcar/OutputView.java +++ b/src/main/java/racingcar/OutputView.java @@ -20,4 +20,9 @@ public void printExecuteResult(){ public void printCarsStatus(Cars cars){ System.out.println(cars.executionResult()); } + + public void printFinalWinner(Cars cars){ + System.out.println(ProgressMessage.FINAL_WINNER); + System.out.println(cars.finalWinner()); + } } From 13cdefd390b5cfb6ce46916077096d2fda015863 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 21:14:09 +0900 Subject: [PATCH 32/41] =?UTF-8?q?feat:=20ProgressMessage=20FINAL=5FWINNER?= =?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/racingcar/ProgressMessage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/racingcar/ProgressMessage.java b/src/main/java/racingcar/ProgressMessage.java index 89dddf9879..840245fad0 100644 --- a/src/main/java/racingcar/ProgressMessage.java +++ b/src/main/java/racingcar/ProgressMessage.java @@ -4,7 +4,8 @@ public enum ProgressMessage { INPUT_CAR_NAMES("경주할 자동차 이름을 입력하세요.(이름은 쉼표(,) 기준으로 구분)"), INPUT_TRY_COUNT("시도할 회수는 몇회인가요?"), - EXECUTE_RESULT("실행 결과"); + EXECUTE_RESULT("실행 결과"), + FINAL_WINNER("최종 우승자 : "); private final String message; From 2c47b76581b544836aa0a73dc54c7da450a6f480 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 21:14:32 +0900 Subject: [PATCH 33/41] =?UTF-8?q?feat:=20controller=20run=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/racingcar/RacingCarController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/racingcar/RacingCarController.java b/src/main/java/racingcar/RacingCarController.java index 8fed81ec8a..aed27a22a5 100644 --- a/src/main/java/racingcar/RacingCarController.java +++ b/src/main/java/racingcar/RacingCarController.java @@ -18,6 +18,7 @@ public void run(){ outputView.printExecuteResult(); changeCarsStatus(cars, tryCount); + outputView.printFinalWinner(cars); } private void changeCarsStatus(Cars cars, int tryCount) { From e181959e9a789f26f6d6d21a25340c2ebd27a364 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 21:14:46 +0900 Subject: [PATCH 34/41] =?UTF-8?q?test:=20=EA=B2=8C=EC=9E=84=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=9D=B4=EA=B8=B4=20=EC=B5=9C=EC=A2=85=20=EC=9A=B0?= =?UTF-8?q?=EC=8A=B9=EC=9E=90=EC=9D=98=20=EC=9D=B4=EB=A6=84=EC=9D=84=20?= =?UTF-8?q?=EB=82=98=ED=83=80=EB=82=9C=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/racingcar/CarsTest.java | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/test/java/racingcar/CarsTest.java b/src/test/java/racingcar/CarsTest.java index 535e2107d7..bc60ed4ec3 100644 --- a/src/test/java/racingcar/CarsTest.java +++ b/src/test/java/racingcar/CarsTest.java @@ -1,12 +1,20 @@ package racingcar; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.*; class CarsTest { - Cars cars = new Cars(); + private Cars cars; + + @BeforeEach + void setUp() { + cars = new Cars(); + cars.addCars("pobi,woni,jun"); + cars.moveCars(); + } @Test @DisplayName("자동차를 추가했을 때 차를 움직이면 실행결과에 이름이 나타난다.") @@ -16,8 +24,16 @@ void showCarScreen(){ String screen = cars.executionResult(); - assertThat(screen).containsOnlyOnce("pobi :"); - assertThat(screen).containsOnlyOnce("woni :"); - assertThat(screen).containsOnlyOnce("jun :"); + assertThat(screen).containsAnyOf("pobi :", "woni :", "jun :"); + } + + @Test + @DisplayName("게임에서 이긴 최종 우승자의 이름을 나타난다.") + void showWinCarNames(){ + cars.addCars("pobi,woni,jun"); + cars.moveCars(); + + String names = cars.finalWinner(); + assertThat(names).containsAnyOf("pobi", "woni", "jun"); } } From 064c898458515ced6409592da4d079381ccc96b3 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 21:18:12 +0900 Subject: [PATCH 35/41] =?UTF-8?q?feat:=20main=20=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/racingcar/Application.java | 3 ++- src/main/java/racingcar/InputView.java | 1 + src/main/java/racingcar/OutputView.java | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/racingcar/Application.java b/src/main/java/racingcar/Application.java index b9ed0456a3..5a3f8ba164 100644 --- a/src/main/java/racingcar/Application.java +++ b/src/main/java/racingcar/Application.java @@ -2,6 +2,7 @@ public class Application { public static void main(String[] args) { - // TODO 구현 진행 + RacingCarController racingCarController = new RacingCarController(); + racingCarController.run(); } } diff --git a/src/main/java/racingcar/InputView.java b/src/main/java/racingcar/InputView.java index fd7117697e..b7873f13d3 100644 --- a/src/main/java/racingcar/InputView.java +++ b/src/main/java/racingcar/InputView.java @@ -24,6 +24,7 @@ public int readTryCount(){ return read(() ->{ outputView.printInputTryCount(); int count = scan.nextInt(); + outputView.printEnter(); inputValidator.validateTryCount(count); return count; }); diff --git a/src/main/java/racingcar/OutputView.java b/src/main/java/racingcar/OutputView.java index 0c02b0cae9..8e8b859451 100644 --- a/src/main/java/racingcar/OutputView.java +++ b/src/main/java/racingcar/OutputView.java @@ -22,7 +22,11 @@ public void printCarsStatus(Cars cars){ } public void printFinalWinner(Cars cars){ - System.out.println(ProgressMessage.FINAL_WINNER); + System.out.print(ProgressMessage.FINAL_WINNER); System.out.println(cars.finalWinner()); } + + public void printEnter(){ + System.out.println(); + } } From 3f22d55f5b2e8c8f73e9fea3618cc6d7486741b1 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 21:42:39 +0900 Subject: [PATCH 36/41] =?UTF-8?q?refactor:=20import=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/racingcar/CreateRandomValue.java | 12 ++++++------ src/main/java/racingcar/InputView.java | 9 ++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/racingcar/CreateRandomValue.java b/src/main/java/racingcar/CreateRandomValue.java index 717332049a..26666982a5 100644 --- a/src/main/java/racingcar/CreateRandomValue.java +++ b/src/main/java/racingcar/CreateRandomValue.java @@ -1,15 +1,15 @@ package racingcar; -import java.util.Random; +import camp.nextstep.edu.missionutils.Randoms; public class CreateRandomValue { - private static final int MAX_RANDOM_NUMBER = 10; - private static final int MIN_RANDOM_VALUE = 4; - private static final Random random = new Random(); + private static final int MIN_RANDOM_VALUE = 0; + private static final int MAX_RANDOM_VALUE = 9; + private static final int MIN_RANDOM_RANGE = 4; public static boolean canMoveCar() { - int randomNumber = random.nextInt(MAX_RANDOM_NUMBER); - return randomNumber >= MIN_RANDOM_VALUE; + int randomNumber = Randoms.pickNumberInRange(MIN_RANDOM_VALUE, MAX_RANDOM_VALUE); + return randomNumber >= MIN_RANDOM_RANGE; } } \ No newline at end of file diff --git a/src/main/java/racingcar/InputView.java b/src/main/java/racingcar/InputView.java index b7873f13d3..1ad018ac6d 100644 --- a/src/main/java/racingcar/InputView.java +++ b/src/main/java/racingcar/InputView.java @@ -1,18 +1,17 @@ package racingcar; -import java.util.Scanner; import java.util.function.Supplier; +import camp.nextstep.edu.missionutils.Console; public class InputView { private final OutputView outputView = new OutputView(); public final InputValidator inputValidator = new InputValidator(); - private final Scanner scan = new Scanner(System.in); public Cars readCarNames(){ return read(() -> { outputView.printInputCarNames(); - String names = scan.next(); + String names = Console.readLine(); inputValidator.validateContainDivision(names); Cars cars = new Cars(); cars.addCars(names); @@ -23,10 +22,10 @@ public Cars readCarNames(){ public int readTryCount(){ return read(() ->{ outputView.printInputTryCount(); - int count = scan.nextInt(); + String count = Console.readLine(); outputView.printEnter(); inputValidator.validateTryCount(count); - return count; + return Integer.parseInt(count); }); } From 82442ce76384edfa485af338a14ff123224eb2ac Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 21:43:12 +0900 Subject: [PATCH 37/41] =?UTF-8?q?refactor:=20InputValidator=20validateNume?= =?UTF-8?q?ric=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/racingcar/ErrorMessage.java | 3 ++- src/main/java/racingcar/InputValidator.java | 11 +++++++++-- src/test/java/racingcar/InputValidatorTest.java | 11 ++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/racingcar/ErrorMessage.java b/src/main/java/racingcar/ErrorMessage.java index ff46717438..1eb659f774 100644 --- a/src/main/java/racingcar/ErrorMessage.java +++ b/src/main/java/racingcar/ErrorMessage.java @@ -3,7 +3,8 @@ public enum ErrorMessage { NAME_DIVISION_ERROR("이름은 쉼표(,) 기준으로 구분합니다."), NAME_LENGTH_ERROR("자동차 이름이름은 5자 이하만 가능합니다."), - TRY_COUNT_ERROR("시도할 회수는 1회 이상입니다."); + TRY_COUNT_ERROR("시도할 회수는 1회 이상입니다."), + INPUT_NUMERIC_ERROR("숫자가 아닙니다."); private static final String ERROR = "[ERROR]"; private final String message; diff --git a/src/main/java/racingcar/InputValidator.java b/src/main/java/racingcar/InputValidator.java index f35d8d25b7..d84f7d27b0 100644 --- a/src/main/java/racingcar/InputValidator.java +++ b/src/main/java/racingcar/InputValidator.java @@ -17,9 +17,16 @@ public void validateContainDivision(String name) { } } - public void validateTryCount(int count) { - if (count < MIN_TRY_COUNT){ + public void validateTryCount(String count) { + validateNumeric(count); + if (Integer.parseInt(count) < MIN_TRY_COUNT){ throw new IllegalArgumentException(ErrorMessage.TRY_COUNT_ERROR.getMessage()); } } + + private void validateNumeric(String count){ + if (!count.matches("^\\d*$")){ + throw new IllegalArgumentException(ErrorMessage.INPUT_NUMERIC_ERROR.getMessage()); + } + } } diff --git a/src/test/java/racingcar/InputValidatorTest.java b/src/test/java/racingcar/InputValidatorTest.java index 185de5fabf..91c9e50516 100644 --- a/src/test/java/racingcar/InputValidatorTest.java +++ b/src/test/java/racingcar/InputValidatorTest.java @@ -28,8 +28,17 @@ void inputCarNamesLength(){ @Test @DisplayName("시도할 횟수가 1회 이상이 아니라면 에러가 발생한다.") void inputTryCount(){ - assertThatThrownBy(() -> inputValidator.validateTryCount(0)) + assertThatThrownBy(() -> inputValidator.validateTryCount("0")) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining(ERROR); } + + @Test + @DisplayName("시도할 횟수가 숫자가 아니라면 에러가 발생한다.") + void inputTryCountNumeric(){ + assertThatThrownBy(() -> inputValidator.validateTryCount("a")) + .isInstanceOf(IllegalArgumentException.class) + .hasMessageContaining(ERROR); + } + } From b8c756668d1c3b246f356e8d638caee71b933509 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 21:55:25 +0900 Subject: [PATCH 38/41] =?UTF-8?q?refactor:=20=EC=83=81=EC=88=98=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=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/racingcar/Cars.java | 13 +++++++++---- src/main/java/racingcar/InputValidator.java | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/racingcar/Cars.java b/src/main/java/racingcar/Cars.java index d0937c1454..dfb9a1d8f4 100644 --- a/src/main/java/racingcar/Cars.java +++ b/src/main/java/racingcar/Cars.java @@ -7,7 +7,12 @@ import java.util.stream.Collectors; public class Cars { + + private static final int OVER_ONE_WINNER = 1; + private static final int ONLY_ONE_WINNER = 0; + private static final int DEFAULT_POSITION = 0; private static final String DIVISION = ","; + private static final String WINNER_DELIMITER = ", "; private final List cars = new ArrayList<>(); public void addCars(String name){ @@ -33,10 +38,10 @@ public String executionResult(){ public String finalWinner(){ List winCars = getWinCarNames(); - if (winCars.size() > 1) { - return String.join(", ", winCars); + if (winCars.size() > OVER_ONE_WINNER) { + return String.join(WINNER_DELIMITER, winCars); } - return winCars.get(0); + return winCars.get(ONLY_ONE_WINNER); } private List getWinCarNames() { @@ -50,7 +55,7 @@ private int maxPosition(){ return cars.stream() .mapToInt(Car::getPosition) .max() - .orElse(0); + .orElse(DEFAULT_POSITION); } } diff --git a/src/main/java/racingcar/InputValidator.java b/src/main/java/racingcar/InputValidator.java index d84f7d27b0..93aa573603 100644 --- a/src/main/java/racingcar/InputValidator.java +++ b/src/main/java/racingcar/InputValidator.java @@ -9,6 +9,7 @@ public class InputValidator { private static final int MIN_TRY_COUNT = 1; private static final int MIN_NAME_SIZE = 2; private static final String DIVISION = ","; + private static final String NUMERIC_REGEX = "^\\d*$"; public void validateContainDivision(String name) { Set carNames = Arrays.stream(name.split(DIVISION)).collect(Collectors.toSet()); @@ -25,7 +26,7 @@ public void validateTryCount(String count) { } private void validateNumeric(String count){ - if (!count.matches("^\\d*$")){ + if (!count.matches(NUMERIC_REGEX)){ throw new IllegalArgumentException(ErrorMessage.INPUT_NUMERIC_ERROR.getMessage()); } } From 97da3e9b8acf852337d73e42017e18da8aa04da0 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 22:00:33 +0900 Subject: [PATCH 39/41] =?UTF-8?q?refactor:=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=20=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/racingcar/Application.java | 2 ++ .../java/racingcar/{ => constants}/ProgressMessage.java | 2 +- .../racingcar/{ => controller}/RacingCarController.java | 7 ++++++- src/main/java/racingcar/{ => domain}/Car.java | 4 +++- src/main/java/racingcar/{ => domain}/Cars.java | 2 +- .../java/racingcar/{ => domain}/CreateRandomValue.java | 2 +- .../java/racingcar/{ => service}/RacingCarService.java | 4 +++- src/main/java/racingcar/{ => view}/InputValidator.java | 4 +++- src/main/java/racingcar/{ => view}/InputView.java | 3 ++- src/main/java/racingcar/{ => view}/OutputView.java | 5 ++++- src/test/java/racingcar/CarsTest.java | 2 ++ src/test/java/racingcar/InputValidatorTest.java | 3 +++ 12 files changed, 31 insertions(+), 9 deletions(-) rename src/main/java/racingcar/{ => constants}/ProgressMessage.java (94%) rename src/main/java/racingcar/{ => controller}/RacingCarController.java (82%) rename src/main/java/racingcar/{ => domain}/Car.java (93%) rename src/main/java/racingcar/{ => domain}/Cars.java (98%) rename src/main/java/racingcar/{ => domain}/CreateRandomValue.java (94%) rename src/main/java/racingcar/{ => service}/RacingCarService.java (64%) rename src/main/java/racingcar/{ => view}/InputValidator.java (94%) rename src/main/java/racingcar/{ => view}/InputView.java (95%) rename src/main/java/racingcar/{ => view}/OutputView.java (88%) diff --git a/src/main/java/racingcar/Application.java b/src/main/java/racingcar/Application.java index 5a3f8ba164..667ba1f98d 100644 --- a/src/main/java/racingcar/Application.java +++ b/src/main/java/racingcar/Application.java @@ -1,5 +1,7 @@ package racingcar; +import racingcar.controller.RacingCarController; + public class Application { public static void main(String[] args) { RacingCarController racingCarController = new RacingCarController(); diff --git a/src/main/java/racingcar/ProgressMessage.java b/src/main/java/racingcar/constants/ProgressMessage.java similarity index 94% rename from src/main/java/racingcar/ProgressMessage.java rename to src/main/java/racingcar/constants/ProgressMessage.java index 840245fad0..71c516b2d0 100644 --- a/src/main/java/racingcar/ProgressMessage.java +++ b/src/main/java/racingcar/constants/ProgressMessage.java @@ -1,4 +1,4 @@ -package racingcar; +package racingcar.constants; public enum ProgressMessage { diff --git a/src/main/java/racingcar/RacingCarController.java b/src/main/java/racingcar/controller/RacingCarController.java similarity index 82% rename from src/main/java/racingcar/RacingCarController.java rename to src/main/java/racingcar/controller/RacingCarController.java index aed27a22a5..019eec7a0a 100644 --- a/src/main/java/racingcar/RacingCarController.java +++ b/src/main/java/racingcar/controller/RacingCarController.java @@ -1,4 +1,9 @@ -package racingcar; +package racingcar.controller; + +import racingcar.domain.Cars; +import racingcar.view.InputView; +import racingcar.view.OutputView; +import racingcar.service.RacingCarService; public class RacingCarController { diff --git a/src/main/java/racingcar/Car.java b/src/main/java/racingcar/domain/Car.java similarity index 93% rename from src/main/java/racingcar/Car.java rename to src/main/java/racingcar/domain/Car.java index 4ffcd79e89..229a8a1888 100644 --- a/src/main/java/racingcar/Car.java +++ b/src/main/java/racingcar/domain/Car.java @@ -1,4 +1,6 @@ -package racingcar; +package racingcar.domain; + +import racingcar.constants.ErrorMessage; public class Car { private static final int MAX_NAME_LENGTH = 5; diff --git a/src/main/java/racingcar/Cars.java b/src/main/java/racingcar/domain/Cars.java similarity index 98% rename from src/main/java/racingcar/Cars.java rename to src/main/java/racingcar/domain/Cars.java index dfb9a1d8f4..b3a0147bef 100644 --- a/src/main/java/racingcar/Cars.java +++ b/src/main/java/racingcar/domain/Cars.java @@ -1,4 +1,4 @@ -package racingcar; +package racingcar.domain; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/racingcar/CreateRandomValue.java b/src/main/java/racingcar/domain/CreateRandomValue.java similarity index 94% rename from src/main/java/racingcar/CreateRandomValue.java rename to src/main/java/racingcar/domain/CreateRandomValue.java index 26666982a5..d08f62d510 100644 --- a/src/main/java/racingcar/CreateRandomValue.java +++ b/src/main/java/racingcar/domain/CreateRandomValue.java @@ -1,4 +1,4 @@ -package racingcar; +package racingcar.domain; import camp.nextstep.edu.missionutils.Randoms; diff --git a/src/main/java/racingcar/RacingCarService.java b/src/main/java/racingcar/service/RacingCarService.java similarity index 64% rename from src/main/java/racingcar/RacingCarService.java rename to src/main/java/racingcar/service/RacingCarService.java index aaaf6b7b63..c510536e42 100644 --- a/src/main/java/racingcar/RacingCarService.java +++ b/src/main/java/racingcar/service/RacingCarService.java @@ -1,4 +1,6 @@ -package racingcar; +package racingcar.service; + +import racingcar.domain.Cars; public class RacingCarService { diff --git a/src/main/java/racingcar/InputValidator.java b/src/main/java/racingcar/view/InputValidator.java similarity index 94% rename from src/main/java/racingcar/InputValidator.java rename to src/main/java/racingcar/view/InputValidator.java index 93aa573603..a84d48c998 100644 --- a/src/main/java/racingcar/InputValidator.java +++ b/src/main/java/racingcar/view/InputValidator.java @@ -1,4 +1,6 @@ -package racingcar; +package racingcar.view; + +import racingcar.constants.ErrorMessage; import java.util.Arrays; import java.util.Set; diff --git a/src/main/java/racingcar/InputView.java b/src/main/java/racingcar/view/InputView.java similarity index 95% rename from src/main/java/racingcar/InputView.java rename to src/main/java/racingcar/view/InputView.java index 1ad018ac6d..2909a96081 100644 --- a/src/main/java/racingcar/InputView.java +++ b/src/main/java/racingcar/view/InputView.java @@ -1,7 +1,8 @@ -package racingcar; +package racingcar.view; import java.util.function.Supplier; import camp.nextstep.edu.missionutils.Console; +import racingcar.domain.Cars; public class InputView { diff --git a/src/main/java/racingcar/OutputView.java b/src/main/java/racingcar/view/OutputView.java similarity index 88% rename from src/main/java/racingcar/OutputView.java rename to src/main/java/racingcar/view/OutputView.java index 8e8b859451..9e93298801 100644 --- a/src/main/java/racingcar/OutputView.java +++ b/src/main/java/racingcar/view/OutputView.java @@ -1,4 +1,7 @@ -package racingcar; +package racingcar.view; + +import racingcar.constants.ProgressMessage; +import racingcar.domain.Cars; public class OutputView { public void printErrorMessage(String message) { diff --git a/src/test/java/racingcar/CarsTest.java b/src/test/java/racingcar/CarsTest.java index bc60ed4ec3..911c3c6650 100644 --- a/src/test/java/racingcar/CarsTest.java +++ b/src/test/java/racingcar/CarsTest.java @@ -3,6 +3,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import racingcar.domain.Cars; + import static org.assertj.core.api.Assertions.*; class CarsTest { diff --git a/src/test/java/racingcar/InputValidatorTest.java b/src/test/java/racingcar/InputValidatorTest.java index 91c9e50516..6fd2cb7969 100644 --- a/src/test/java/racingcar/InputValidatorTest.java +++ b/src/test/java/racingcar/InputValidatorTest.java @@ -2,6 +2,9 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import racingcar.domain.Car; +import racingcar.view.InputValidator; + import static org.assertj.core.api.Assertions.*; class InputValidatorTest { From 8cb44337c10945f7476c4d3107a9a8e4dfe7a81d Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 22:00:40 +0900 Subject: [PATCH 40/41] =?UTF-8?q?refactor:=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=20=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/racingcar/{ => constants}/ErrorMessage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/racingcar/{ => constants}/ErrorMessage.java (94%) diff --git a/src/main/java/racingcar/ErrorMessage.java b/src/main/java/racingcar/constants/ErrorMessage.java similarity index 94% rename from src/main/java/racingcar/ErrorMessage.java rename to src/main/java/racingcar/constants/ErrorMessage.java index 1eb659f774..2e2cc1da59 100644 --- a/src/main/java/racingcar/ErrorMessage.java +++ b/src/main/java/racingcar/constants/ErrorMessage.java @@ -1,4 +1,4 @@ -package racingcar; +package racingcar.constants; public enum ErrorMessage { NAME_DIVISION_ERROR("이름은 쉼표(,) 기준으로 구분합니다."), From 8621d8bb755ec0d219fb1ca7f7d68d3a9e361aed Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Fri, 8 Sep 2023 22:00:51 +0900 Subject: [PATCH 41/41] =?UTF-8?q?docs:=20=EB=A6=AC=EB=93=9C=EB=AF=B8=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 --- docs/Readme.md | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/docs/Readme.md b/docs/Readme.md index 70ff132998..e1df789ce7 100644 --- a/docs/Readme.md +++ b/docs/Readme.md @@ -1,25 +1,29 @@ ## 기능 구현 - Car - - 각 자동차에 이름을 부여할 수 있다. 전진하는 자동차를 출력할 때 자동차 이름을 같이 출력한다. - - 자동차 이름은 쉼표(,)를 기준으로 구분하며 이름은 5자 이하만 가능하다. - - 자동차의 개수는 2대 이상 + - [x] 각 자동차에 이름을 부여할 수 있다. 전진하는 자동차를 출력할 때 자동차 이름을 같이 출력한다. + - [x] 자동차 이름은 쉼표(,)를 기준으로 구분하며 이름은 5자 이하만 가능하다. + - [x] 자동차의 개수는 2대 이상 - Cars - - 주어진 횟수 동안 n대의 자동차는 전진 또는 멈출 수 있다. + - [x] 자동차들을 추가할 수 있다. + - [x] 주어진 횟수 동안 n대의 자동차는 전진 또는 멈출 수 있다. + - [x] 자동차 상태를 문자열로 확인할 수 있다. + - [x] 우승 자동차를 확인할 수 찾을 수 있다. - InputView - - 경주 할 자동차 이름을 입력한다(이름은 쉼표(,) 기준으로 구분) - - 사용자는 몇 번의 이동을 할 것인지를 입력한다. + - [x] 경주 할 자동차 이름을 입력한다(이름은 쉼표(,) 기준으로 구분) + - [x] 사용자는 몇 번의 이동을 할 것인지를 입력한다. -- AdvanceCondition - - 전진하는 조건은 0에서 9 사이에서 무작위 값을 구한 후 무작위 값이 4 이상일 경우이다. +- CreateRandomValue + - [x] 전진하는 조건은 0에서 9 사이에서 무작위 값을 구한 후 무작위 값이 4 이상일 경우이다. - OutputView - - 실행 결과 출력 - - 자동차 경주 게임을 완료한 후 누가 우승했는지를 알려준다. 우승자는 한 명 이상일 수 있다. - - 우승자가 여러 명일 경우 쉼표(,)를 이용하여 구분한다. + - [x] 실행 결과 출력 + - [x] 최종 결과 출력 -> 자동차 경주 게임을 완료한 후 누가 우승했는지를 알려준다. 우승자는 한 명 이상일 수 있다. + - [x] 우승자가 여러 명일 경우 쉼표(,)를 이용하여 구분한다. - InputValidator - - 사용자가 잘못된 값을 입력할 경우 IllegalArgumentException를 발생시키고, - - "[ERROR]"로 시작하는 에러 메시지를 출력 후 그 부분부터 입력을 다시 받는다. - - 쉼표로 구분 \ No newline at end of file + - [x] 사용자가 잘못된 값을 입력할 경우 IllegalArgumentException를 발생시키고, + - [x] "[ERROR]"로 시작하는 에러 메시지를 출력 후 그 부분부터 입력을 다시 받는다. + - [x] 쉼표로 구분 + - [x] 시도 횟수 숫자 확인 \ No newline at end of file