diff --git a/README.md b/README.md
index 5fa2560b46..13907455d5 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,106 @@
# java-lotto-precourse
+
+## ๐ ๋ฏธ์
์์ธ
+
+๊ฐ๋จํ ๋ก๋ ๋ฐ๋งค๊ธฐ๋ฅผ ๊ตฌํํ๋ค.
+
+๋ก๋ ๋ฒํธ์ ์ซ์ ๋ฒ์๋ 1~45๊น์ง์ด๋ค.
+1๊ฐ์ ๋ก๋๋ฅผ ๋ฐํํ ๋ ์ค๋ณต๋์ง ์๋ 6๊ฐ์ ์ซ์๋ฅผ ๋ฝ๋๋ค.
+๋น์ฒจ ๋ฒํธ ์ถ์ฒจ ์ ์ค๋ณต๋์ง ์๋ ์ซ์ 6๊ฐ์ ๋ณด๋์ค ๋ฒํธ 1๊ฐ๋ฅผ ๋ฝ๋๋ค.
+๋น์ฒจ์ 1๋ฑ๋ถํฐ 5๋ฑ๊น์ง ์๋ค.
+๋น์ฒจ ๊ธฐ์ค๊ณผ ๊ธ์ก์ ์๋์ ๊ฐ๋ค.
+- 1๋ฑ: 6๊ฐ ๋ฒํธ ์ผ์น / 2,000,000,000์
+- 2๋ฑ: 5๊ฐ ๋ฒํธ + ๋ณด๋์ค ๋ฒํธ ์ผ์น / 30,000,000์
+- 3๋ฑ: 5๊ฐ ๋ฒํธ ์ผ์น / 1,500,000์
+- 4๋ฑ: 4๊ฐ ๋ฒํธ ์ผ์น / 50,000์
+- 5๋ฑ: 3๊ฐ ๋ฒํธ ์ผ์น / 5,000์
+
+๋ก๋ ๊ตฌ์
๊ธ์ก์ ์
๋ ฅํ๋ฉด ๊ตฌ์
๊ธ์ก์ ํด๋นํ๋ ๋งํผ ๋ก๋๋ฅผ ๋ฐํํด์ผ ํ๋ค.
+๋ก๋ 1์ฅ์ ๊ฐ๊ฒฉ์ 1,000์์ด๋ค.
+๋น์ฒจ ๋ฒํธ์ ๋ณด๋์ค ๋ฒํธ๋ฅผ ์
๋ ฅ๋ฐ๋๋ค.
+์ฌ์ฉ์๊ฐ ๊ตฌ๋งคํ ๋ก๋ ๋ฒํธ์ ๋น์ฒจ ๋ฒํธ๋ฅผ ๋น๊ตํ์ฌ ๋น์ฒจ ๋ด์ญ ๋ฐ ์์ต๋ฅ ์ ์ถ๋ ฅํ๊ณ ๋ก๋ ๊ฒ์์ ์ข
๋ฃํ๋ค.
+
+์ฌ์ฉ์๊ฐ ์๋ชป๋ ๊ฐ์ ์
๋ ฅํ ๊ฒฝ์ฐ `IllegalArgumentException`์ ๋ฐ์์ํค๊ณ , "[ERROR]"๋ก ์์ํ๋ ์๋ฌ ๋ฉ์์ง๋ฅผ ์ถ๋ ฅ ํ ๊ทธ ๋ถ๋ถ๋ถํฐ ์
๋ ฅ์ ๋ค์ ๋ฐ๋๋ค.
+Exception์ด ์๋ `IllegalArgumentException`, `IllegalStateException` ๋ฑ๊ณผ ๊ฐ์ ๋ช
ํํ ์ ํ์ ์ฒ๋ฆฌํ๋ค.
+
+
+### ์
๋ ฅ
+1. ๋ก๋ ๊ตฌ์
๊ธ์ก์ ์
๋ ฅ ๋ฐ๋๋ค. ๊ตฌ์
๊ธ์ก์ 1,000์ ๋จ์๋ก ์
๋ ฅ ๋ฐ์ผ๋ฉฐ 1,000์์ผ๋ก ๋๋์ด ๋จ์ด์ง์ง ์๋ ๊ฒฝ์ฐ ์์ธ ์ฒ๋ฆฌํ๋ค.
+```
+14000
+```
+2. ๋น์ฒจ ๋ฒํธ๋ฅผ ์
๋ ฅ ๋ฐ๋๋ค. ๋ฒํธ๋ ์ผํ(,)๋ฅผ ๊ธฐ์ค์ผ๋ก ๊ตฌ๋ถํ๋ค.
+```
+1,2,3,4,5,6
+```
+3. ๋ณด๋์ค ๋ฒํธ๋ฅผ ์
๋ ฅ ๋ฐ๋๋ค.
+```
+7
+```
+
+### ์ถ๋ ฅ
+
+- ๋ฐํํ ๋ก๋ ์๋ ๋ฐ ๋ฒํธ๋ฅผ ์ถ๋ ฅํ๋ค. ๋ก๋ ๋ฒํธ๋ ์ค๋ฆ์ฐจ์์ผ๋ก ์ ๋ ฌํ์ฌ ๋ณด์ฌ์ค๋ค
+```
+8๊ฐ๋ฅผ ๊ตฌ๋งคํ์ต๋๋ค.
+[8, 21, 23, 41, 42, 43]
+[3, 5, 11, 16, 32, 38]
+[7, 11, 16, 35, 36, 44]
+[1, 8, 11, 31, 41, 42]
+[13, 14, 16, 38, 42, 45]
+[7, 11, 30, 40, 42, 43]
+[2, 13, 22, 32, 38, 45]
+[1, 3, 5, 14, 22, 45]
+```
+- ๋น์ฒจ ๋ด์ญ์ ์ถ๋ ฅํ๋ค.
+```
+3๊ฐ ์ผ์น (5,000์) - 1๊ฐ
+4๊ฐ ์ผ์น (50,000์) - 0๊ฐ
+5๊ฐ ์ผ์น (1,500,000์) - 0๊ฐ
+5๊ฐ ์ผ์น, ๋ณด๋์ค ๋ณผ ์ผ์น (30,000,000์) - 0๊ฐ
+6๊ฐ ์ผ์น (2,000,000,000์) - 0๊ฐ
+```
+- ์์ต๋ฅ ์ ์์์ ๋์งธ ์๋ฆฌ์์ ๋ฐ์ฌ๋ฆผํ๋ค. (ex. 100.0%, 51.5%, 1,000,000.0%)
+```
+์ด ์์ต๋ฅ ์ 62.5%์
๋๋ค.
+```
+์์ธ ์ํฉ ์ ์๋ฌ ๋ฌธ๊ตฌ๋ฅผ ์ถ๋ ฅํด์ผ ํ๋ค. ๋จ, ์๋ฌ ๋ฌธ๊ตฌ๋ "[ERROR]"๋ก ์์ํด์ผ ํ๋ค.
+```
+[ERROR] ๋ก๋ ๋ฒํธ๋ 1๋ถํฐ 45 ์ฌ์ด์ ์ซ์์ฌ์ผ ํฉ๋๋ค.
+```
+
+
+## ๐ ๊ธฐ๋ฅ ๊ตฌํ ๋ชฉ๋ก
+
+- [x] **๋ก๋ ๊ตฌ์
๊ธ์ก ์
๋ ฅ ๋ฐ๊ธฐ**
+ - [x] 1,000์ ๋จ์๋ก ์
๋ ฅ๋ ๊ธ์ก์ธ์ง ํ์ธ
+ - [x] ์
๋ ฅ ๊ธ์ก์ด 1,000์์ผ๋ก ๋๋์ด ๋จ์ด์ง์ง ์๋์ง ๊ฒ์ฆ
+
+- [x] **๋ก๋ ๋ฒํธ ์์ฑ ๋ฐ ๋ฐํ**
+ - [x] ์
๋ ฅ๋ ๊ธ์ก์ ๋ฐ๋ผ ๋ฐํํ ๋ก๋ ์๋ ๊ณ์ฐ
+ - [x] ๋ก๋ ๋ฒํธ ๋ฒ์(1~45) ๋ด์์ ์ค๋ณต๋์ง ์๋ 6๊ฐ์ ๋ฒํธ ์์ฑ
+ - [x] ์์ฑ๋ ๋ก๋ ๋ฒํธ๋ฅผ ์ค๋ฆ์ฐจ์์ผ๋ก ์ ๋ ฌ
+ - [x] ๋ฐํ๋ ๋ก๋ ์๋๊ณผ ๊ฐ๊ฐ์ ๋ก๋ ๋ฒํธ๋ฅผ ์ถ๋ ฅ
+
+- [x] **๋น์ฒจ ๋ฒํธ์ ๋ณด๋์ค ๋ฒํธ ์
๋ ฅ ๋ฐ๊ธฐ**
+ - [x] ๋น์ฒจ ๋ฒํธ 6๊ฐ๋ฅผ ์ผํ(,)๋ก ๊ตฌ๋ถํ์ฌ ์
๋ ฅ ๋ฐ๊ธฐ
+ - [x] ์
๋ ฅ๋ ๋ฒํธ๋ค์ด 1~45 ๋ฒ์ ๋ด์ ์ซ์์ธ์ง ๊ฒ์ฆ
+ - [x] ๋ณด๋์ค ๋ฒํธ๊ฐ 1~45 ๋ฒ์ ๋ด์ ์ซ์์ธ์ง ๊ฒ์ฆ
+ - [x] ๋น์ฒจ ๋ฒํธ์ ์ค๋ณต๋์ง ์๋์ง ํ์ธ
+ - [x] ์
๋ ฅ๊ฐ์ด ์ ํจํ์ง ์๋์ง ๊ฒ์ฆ
+
+- [x] **๋ก๋ ๋น์ฒจ ํ์ธ**
+ - [x] ์ฌ์ฉ์๊ฐ ๊ตฌ๋งคํ ๊ฐ ๋ก๋ ๋ฒํธ์ ๋น์ฒจ ๋ฒํธ๋ฅผ ๋น๊ต
+ - [x] ๋น์ฒจ ๊ธฐ์ค์ ๋ฐ๋ผ 1๋ฑ๋ถํฐ 5๋ฑ๊น์ง ๋น์ฒจ ์ฌ๋ถ์ ๊ฐ์๋ฅผ ํ๋ณ
+
+- [x] **๋น์ฒจ ๋ด์ญ ์ถ๋ ฅ**
+ - [x] ๊ฐ ๋ฑ์๋ณ ์ผ์นํ๋ ๋ก๋ ๊ฐ์๋ฅผ ์ถ๋ ฅ
+ - [x] ๋น์ฒจ ๊ธ์ก์ ๊ฐ ๋ฑ์๋ณ๋ก ์ถ๋ ฅ ํ์์ ๋ง๊ฒ ํ์
+
+- [x] **์์ต๋ฅ ๊ณ์ฐ**
+ - [x] ์ฌ์ฉ์๊ฐ ๊ตฌ๋งคํ ๋ก๋ ์ด ๊ธ์ก๊ณผ ๋น์ฒจ ๊ธ์ก์ ๋น๊ตํ์ฌ ์์ต๋ฅ ๊ณ์ฐ
+ - [x] ์์ต๋ฅ ์ ์์์ ๋์งธ ์๋ฆฌ์์ ๋ฐ์ฌ๋ฆผํ์ฌ ์ถ๋ ฅ
+
+- [x] **์์ธ ์ฒ๋ฆฌ**
+ - [x] ์
๋ ฅ ๊ฐ์ด ์๋ชป๋์์ ๋ `IllegalArgumentException`์ ๋ฐ์์ํค๊ณ `[ERROR]` ๋ฉ์์ง๋ฅผ ์ถ๋ ฅ
+ - [x] ์๋ชป๋ ๊ฐ์ด ์
๋ ฅ๋ ๊ฒฝ์ฐ ํด๋น ๋ถ๋ถ๋ถํฐ ์
๋ ฅ์ ๋ค์ ๋ฐ๋๋ก ๊ตฌํ
\ No newline at end of file
diff --git a/src/main/java/lotto/Application.java b/src/main/java/lotto/Application.java
index d190922ba4..6242293005 100644
--- a/src/main/java/lotto/Application.java
+++ b/src/main/java/lotto/Application.java
@@ -1,7 +1,9 @@
package lotto;
+import lotto.runner.Runner;
+
public class Application {
public static void main(String[] args) {
- // TODO: ํ๋ก๊ทธ๋จ ๊ตฌํ
+ Runner.run();
}
}
diff --git a/src/main/java/lotto/Lotto.java b/src/main/java/lotto/Lotto.java
deleted file mode 100644
index 88fc5cf12b..0000000000
--- a/src/main/java/lotto/Lotto.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package lotto;
-
-import java.util.List;
-
-public class Lotto {
- private final List numbers;
-
- public Lotto(List numbers) {
- validate(numbers);
- this.numbers = numbers;
- }
-
- private void validate(List numbers) {
- if (numbers.size() != 6) {
- throw new IllegalArgumentException("[ERROR] ๋ก๋ ๋ฒํธ๋ 6๊ฐ์ฌ์ผ ํฉ๋๋ค.");
- }
- }
-
- // TODO: ์ถ๊ฐ ๊ธฐ๋ฅ ๊ตฌํ
-}
diff --git a/src/main/java/lotto/application/LottoGenerator.java b/src/main/java/lotto/application/LottoGenerator.java
new file mode 100644
index 0000000000..06332aa660
--- /dev/null
+++ b/src/main/java/lotto/application/LottoGenerator.java
@@ -0,0 +1,27 @@
+package lotto.application;
+
+import camp.nextstep.edu.missionutils.Randoms;
+import lotto.domain.Lotto;
+
+import java.util.List;
+
+public class LottoGenerator {
+
+ private static LottoGenerator instance;
+
+ private LottoGenerator() {
+
+ }
+
+ public static LottoGenerator getInstance() {
+ if (instance == null) {
+ instance = new LottoGenerator();
+ }
+ return instance;
+ }
+
+ public Lotto generate() {
+ List LottoNumbers = Randoms.pickUniqueNumbersInRange(1, 45, 6);
+ return Lotto.of(LottoNumbers);
+ }
+}
diff --git a/src/main/java/lotto/application/LottoService.java b/src/main/java/lotto/application/LottoService.java
new file mode 100644
index 0000000000..688e0b8970
--- /dev/null
+++ b/src/main/java/lotto/application/LottoService.java
@@ -0,0 +1,55 @@
+package lotto.application;
+
+import lotto.domain.Lotto;
+import lotto.global.LottoPrize;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class LottoService {
+
+ private static final int LOTTO_PRICE = 1000;
+ private static LottoService instance;
+ private final LottoGenerator lottoGenerator;
+
+ private LottoService(LottoGenerator lottoGenerator) {
+ this.lottoGenerator = lottoGenerator;
+ }
+
+ public static LottoService getInstance(LottoGenerator lottoGenerator) {
+ if (instance == null) {
+ instance = new LottoService(lottoGenerator);
+ }
+ return instance;
+ }
+
+ public List buyLottos(int price) {
+ LottoValidator.validatePurchasePrice(price);
+ List lottos = new ArrayList<>();
+
+ for(int i = 0; i < price / LOTTO_PRICE; i++) {
+ lottos.add(lottoGenerator.generate());
+ }
+
+ return lottos;
+ }
+
+ public LottoPrize calculatePrize(Lotto myLotto, Lotto lottoResult, int bonusNumber) {
+ LottoValidator.validateBonusNumber(bonusNumber, lottoResult.getNumbers());
+ long matchLottoCount = myLotto.getNumbers().stream()
+ .filter(lottoResult.getNumbers()::contains)
+ .count();
+
+ boolean matchBonusNumber = myLotto.getNumbers().contains(bonusNumber);
+
+ return LottoPrize.from(matchLottoCount, matchBonusNumber);
+ }
+
+ public Double calculateProfitRate(List results, int purchaseQuantity) {
+ int totalPrize = results.stream()
+ .map(result -> result.getPrizeMoney().replace(",", ""))
+ .mapToInt(Integer::parseInt)
+ .sum();
+ return (double) totalPrize / purchaseQuantity;
+ }
+}
diff --git a/src/main/java/lotto/application/LottoValidator.java b/src/main/java/lotto/application/LottoValidator.java
new file mode 100644
index 0000000000..0c16af4152
--- /dev/null
+++ b/src/main/java/lotto/application/LottoValidator.java
@@ -0,0 +1,27 @@
+package lotto.application;
+
+import java.util.List;
+
+public class LottoValidator {
+
+ private static final int LOTTO_PRICE = 1000;
+ private static final int MIN_NUMBER = 1;
+ private static final int MAX_NUMBER = 45;
+
+
+ public static void validatePurchasePrice(int price) {
+ if (price <= 0 || price % LOTTO_PRICE != 0) {
+ throw new IllegalArgumentException("[ERROR] ๊ธ์ก์ 1,000์ ๋จ์๋ก ์
๋ ฅํด์ผ ํฉ๋๋ค.");
+ }
+ }
+
+ public static void validateBonusNumber(int bonusNumber, List winningNumbers) {
+ if (bonusNumber < MIN_NUMBER || bonusNumber > MAX_NUMBER) {
+ throw new IllegalArgumentException("[ERROR] ๋ณด๋์ค ๋ฒํธ๋ 1๋ถํฐ 45 ์ฌ์ด์ ์ซ์์ฌ์ผ ํฉ๋๋ค.");
+ }
+
+ if (winningNumbers.contains(bonusNumber)) {
+ throw new IllegalArgumentException("[ERROR] ๋ณด๋์ค ๋ฒํธ๋ ๋น์ฒจ ๋ฒํธ์ ์ค๋ณต๋ ์ ์์ต๋๋ค.");
+ }
+ }
+}
diff --git a/src/main/java/lotto/domain/Lotto.java b/src/main/java/lotto/domain/Lotto.java
new file mode 100644
index 0000000000..4a25c037b1
--- /dev/null
+++ b/src/main/java/lotto/domain/Lotto.java
@@ -0,0 +1,51 @@
+package lotto.domain;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class Lotto {
+ private final List numbers;
+
+ public Lotto(List numbers) {
+ validateQuantity(numbers);
+ validateNumberRange(numbers);
+ validateDuplicate(numbers);
+ this.numbers = numbers;
+ sortNumbers(this.numbers);
+ }
+
+ public static Lotto of(List numbers) {
+ return new Lotto(numbers);
+ }
+
+ public List getNumbers() {
+ return numbers;
+ }
+
+ private void validateQuantity(List numbers) {
+ if (numbers.size() != 6) {
+ throw new IllegalArgumentException("[ERROR] ๋ก๋ ๋ฒํธ๋ 6๊ฐ์ฌ์ผ ํฉ๋๋ค.");
+ }
+ }
+
+ private void validateNumberRange(List numbers) {
+ for(Integer number : numbers) {
+ if (number < 0 || number > 45) {
+ throw new IllegalArgumentException("[ERROR] ๋ก๋ ๋ฒํธ๋ 1๋ถํฐ 45 ์ฌ์ด์ ์ซ์์ฌ์ผ ํฉ๋๋ค.");
+ }
+ }
+ }
+
+ private void sortNumbers(List numbers) {
+ Collections.sort(numbers);
+ }
+
+ private void validateDuplicate(List numbers) {
+ Set uniqueNumbers = new HashSet<>(numbers);
+ if (uniqueNumbers.size() != numbers.size()) {
+ throw new IllegalArgumentException("[ERROR] ๋ก๋ ๋ฒํธ์ ์ค๋ณต๋ ์ซ์๊ฐ ์์ผ๋ฉด ์๋ฉ๋๋ค.");
+ }
+ }
+}
diff --git a/src/main/java/lotto/global/LottoPrize.java b/src/main/java/lotto/global/LottoPrize.java
new file mode 100644
index 0000000000..25a1b5c3df
--- /dev/null
+++ b/src/main/java/lotto/global/LottoPrize.java
@@ -0,0 +1,45 @@
+package lotto.global;
+
+public enum LottoPrize {
+
+ FIRST(6, false, "2,000,000,000"),
+ SECOND(5, true, "30,000,000"),
+ THIRD(5, false, "1,500,000"),
+ FOURTH(4, false, "50,000"),
+ FIFTH(3, false, "5,000"),
+ NONE(0, false, "0");
+
+ private final int matchNumberCount;
+ private final boolean matchBonusNumber;
+ private final String prizeMoney;
+
+ LottoPrize(int matchNumberCount, boolean matchBonusNumber, String prizeMoney) {
+ this.matchNumberCount = matchNumberCount;
+ this.matchBonusNumber = matchBonusNumber;
+ this.prizeMoney = prizeMoney;
+ }
+
+ public int getMatchNumberCount() {
+ return matchNumberCount;
+ }
+
+ public String getPrizeMoney() {
+ return prizeMoney;
+ }
+
+ public static LottoPrize from(long matchNumberCount, boolean matchBonusNumber) {
+ for (LottoPrize prize : values()) {
+ if (prize.matchNumberCount == matchNumberCount && prize.matchBonusNumber == matchBonusNumber) {
+ return prize;
+ }
+ }
+ return NONE;
+ }
+
+ public String getMatchDescription() {
+ if (matchBonusNumber) {
+ return matchNumberCount + "๊ฐ ์ผ์น, ๋ณด๋์ค ๋ณผ ์ผ์น";
+ }
+ return matchNumberCount + "๊ฐ ์ผ์น";
+ }
+}
diff --git a/src/main/java/lotto/parser/InputParser.java b/src/main/java/lotto/parser/InputParser.java
new file mode 100644
index 0000000000..593d6eabb7
--- /dev/null
+++ b/src/main/java/lotto/parser/InputParser.java
@@ -0,0 +1,23 @@
+package lotto.parser;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class InputParser {
+
+ public static int parseLottoPrice(String lottoPrice) {
+ return Integer.parseInt(lottoPrice);
+ }
+
+ public static List parseLottoNumber(String lottoNumber) {
+ List lottoNumbers = Arrays.asList(lottoNumber.split(","));
+ return lottoNumbers.stream()
+ .map(Integer::parseInt)
+ .collect(Collectors.toList());
+ }
+
+ public static int parseBonusNumber(String bonusNumber) {
+ return Integer.parseInt(bonusNumber);
+ }
+}
diff --git a/src/main/java/lotto/runner/Runner.java b/src/main/java/lotto/runner/Runner.java
new file mode 100644
index 0000000000..2739adcd6e
--- /dev/null
+++ b/src/main/java/lotto/runner/Runner.java
@@ -0,0 +1,52 @@
+package lotto.runner;
+
+import lotto.application.LottoGenerator;
+import lotto.application.LottoService;
+import lotto.domain.Lotto;
+import lotto.global.LottoPrize;
+import lotto.parser.InputParser;
+import lotto.view.InputView;
+import lotto.view.OutputView;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class Runner {
+
+ public static void run() {
+ LottoGenerator lottoGenerator = LottoGenerator.getInstance();
+ LottoService lottoService = LottoService.getInstance(lottoGenerator);
+
+ int lottoPrice = InputParser.parseLottoPrice(InputView.inputLottoPurchase());
+ List purchasedLottos = getLottos(lottoService, lottoPrice);
+
+ List winningLottoNumbers = InputParser.parseLottoNumber(InputView.inputLottoNumber());
+ Lotto winningLotto = Lotto.of(winningLottoNumbers);
+
+ int bonusNumber = InputParser.parseBonusNumber(InputView.inputBonusNumber());
+
+ List results = getLottoPrizes(purchasedLottos, lottoService, winningLotto, bonusNumber);
+
+ getProfitRate(lottoService, results, lottoPrice);
+ }
+
+ private static List getLottos(LottoService lottoService, int lottoPrice) {
+ List purchasedLottos = lottoService.buyLottos(lottoPrice);
+ OutputView.printLottos(purchasedLottos);
+ return purchasedLottos;
+ }
+
+ private static void getProfitRate(LottoService lottoService, List results, int lottoPrice) {
+ double profitRate = lottoService.calculateProfitRate(results, lottoPrice);
+ OutputView.printProfit(profitRate);
+ }
+
+ private static List getLottoPrizes(List purchasedLottos, LottoService lottoService, Lotto winningLotto, int bonusNumber) {
+ List results = purchasedLottos.stream()
+ .map(lotto -> lottoService.calculatePrize(lotto, winningLotto, bonusNumber))
+ .collect(Collectors.toList());
+
+ OutputView.printResult(results);
+ return results;
+ }
+}
diff --git a/src/main/java/lotto/view/InputView.java b/src/main/java/lotto/view/InputView.java
new file mode 100644
index 0000000000..d84b781de5
--- /dev/null
+++ b/src/main/java/lotto/view/InputView.java
@@ -0,0 +1,21 @@
+package lotto.view;
+
+import camp.nextstep.edu.missionutils.Console;
+
+public class InputView {
+
+ public static String inputLottoPurchase() {
+ System.out.println("๊ตฌ์
๊ธ์ก์ ์
๋ ฅํด์ฃผ์ธ์.");
+ return Console.readLine();
+ }
+
+ public static String inputLottoNumber() {
+ System.out.println("๋น์ฒจ ๋ฒํธ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.");
+ return Console.readLine();
+ }
+
+ public static String inputBonusNumber() {
+ System.out.println("๋ณด๋์ค ๋ฒํธ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์");
+ return Console.readLine();
+ }
+}
diff --git a/src/main/java/lotto/view/OutputView.java b/src/main/java/lotto/view/OutputView.java
new file mode 100644
index 0000000000..a9b2215264
--- /dev/null
+++ b/src/main/java/lotto/view/OutputView.java
@@ -0,0 +1,31 @@
+package lotto.view;
+
+import lotto.domain.Lotto;
+import lotto.global.LottoPrize;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
+public class OutputView {
+
+ public static void printLottos(List lottos) {
+ System.out.println(lottos.size() + "๊ฐ๋ฅผ ๊ตฌ๋งคํ์ต๋๋ค.");
+ lottos.forEach(lotto -> System.out.println(lotto.getNumbers()));
+ }
+
+ public static void printResult(List results) {
+ System.out.println("๋น์ฒจ ํต๊ณ");
+ System.out.println("---");
+ Arrays.stream(LottoPrize.values())
+ .filter(prize -> prize != LottoPrize.NONE)
+ .forEach(prize -> {
+ long count = results.stream().filter(prize::equals).count();
+ System.out.println(prize.getMatchDescription() + " (" + prize.getPrizeMoney() + "์) - " + count + "๊ฐ");
+ });
+ }
+
+ public static void printProfit(double profit) {
+ System.out.printf("์ด ์์ต๋ฅ ์ %.1f%%์
๋๋ค.%n", profit * 100);
+ }
+}
diff --git a/src/test/java/lotto/LottoTest.java b/src/test/java/lotto/LottoTest.java
index 309f4e50ae..1d0756794f 100644
--- a/src/test/java/lotto/LottoTest.java
+++ b/src/test/java/lotto/LottoTest.java
@@ -1,10 +1,15 @@
package lotto;
+import lotto.application.LottoService;
+import lotto.domain.Lotto;
+import lotto.global.LottoPrize;
+import lotto.parser.InputParser;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.util.List;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
class LottoTest {
@@ -14,12 +19,16 @@ class LottoTest {
.isInstanceOf(IllegalArgumentException.class);
}
- @DisplayName("๋ก๋ ๋ฒํธ์ ์ค๋ณต๋ ์ซ์๊ฐ ์์ผ๋ฉด ์์ธ๊ฐ ๋ฐ์ํ๋ค.")
@Test
void ๋ก๋_๋ฒํธ์_์ค๋ณต๋_์ซ์๊ฐ_์์ผ๋ฉด_์์ธ๊ฐ_๋ฐ์ํ๋ค() {
assertThatThrownBy(() -> new Lotto(List.of(1, 2, 3, 4, 5, 5)))
.isInstanceOf(IllegalArgumentException.class);
}
- // TODO: ์ถ๊ฐ ๊ธฐ๋ฅ ๊ตฌํ์ ๋ฐ๋ฅธ ํ
์คํธ ์ฝ๋ ์์ฑ
+ @Test
+ void ๋ก๋_๋ฒํธ๊ฐ_6๊ฐ๊ฐ_์๋๋ฉด_์์ธ๊ฐ_๋ฐ์ํ๋ค() {
+ assertThatThrownBy(() -> new Lotto(List.of(1, 2, 3, 4, 5)))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("๋ก๋ ๋ฒํธ๋ 6๊ฐ์ฌ์ผ ํฉ๋๋ค.");
+ }
}