diff --git a/README.md b/README.md
index 81b03cdba2..8faa313cfd 100644
--- a/README.md
+++ b/README.md
@@ -1,207 +1,93 @@
-# ๊ณผ์ - ๋ก๋
-
-## ๐ ์งํ ๋ฐฉ์
-
-- ๊ณผ์ ๋ **๊ธฐ๋ฅ ์๊ตฌ ์ฌํญ, ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ ์ฌํญ, ๊ณผ์ ์งํ ์๊ตฌ ์ฌํญ** ์ธ ๊ฐ์ง๋ก ๊ตฌ์ฑ๋์ด ์๋ค.
-- ์ธ ๊ฐ์ ์๊ตฌ ์ฌํญ์ ๋ง์กฑํ๊ธฐ ์ํด ๋
ธ๋ ฅํ๋ค. ํนํ ๊ธฐ๋ฅ์ ๊ตฌํํ๊ธฐ ์ ์ ๊ธฐ๋ฅ ๋ชฉ๋ก์ ๋ง๋ค๊ณ , ๊ธฐ๋ฅ ๋จ์๋ก ์ปค๋ฐ ํ๋ ๋ฐฉ์์ผ๋ก ์งํํ๋ค.
-- ๊ธฐ๋ฅ ์๊ตฌ ์ฌํญ์ ๊ธฐ์ฌ๋์ง ์์ ๋ด์ฉ์ ์ค์ค๋ก ํ๋จํ์ฌ ๊ตฌํํ๋ค.
-
----
-
-## ๐ ๊ณผ์ ์งํ ๋ฐ ์ ์ถ ๋ฐฉ๋ฒ
-
-- ๊ณผ์ ๋ [java-lotto](https://github.com/LandvibeDev/java-lotto) ์ ์ฅ์๋ฅผ Fork/Cloneํด ์์ํ๋ค.
-- **๊ธฐ๋ฅ์ ๊ตฌํํ๊ธฐ ์ ์ java-baseball-precourse/README.md ํ์ผ์ ๊ตฌํํ ๊ธฐ๋ฅ ๋ชฉ๋ก์ ์ ๋ฆฌ**ํด ์ถ๊ฐํ๋ค.
-- **Git์ ์ปค๋ฐ ๋จ์๋ ์ ๋จ๊ณ์์ README.md ํ์ผ์ ์ ๋ฆฌํ ๊ธฐ๋ฅ ๋ชฉ๋ก ๋จ์**๋ก ์ถ๊ฐํ๋ค.
- - [AngularJS Commit Message Conventions](https://gist.github.com/stephenparish/9941e89d80e2bc58a153) ์ฐธ๊ณ ํด commit log๋ฅผ ๋จ๊ธด๋ค.
-- ๊ณผ์ ์งํ ๋ฐ ์ ์ถ ๋ฐฉ๋ฒ์ [์ฐ์ํ์ฝ์ค ๊ณผ์ ์ ์ถ ๋ฌธ์](https://github.com/woowacourse/woowacourse-docs/tree/master/precourse) ๋ฅผ ์ฐธ๊ณ ํ๋ค.
- - base repository๋ฅผ `LandvibeDev/java-lotto`๋ก ์ง์ ํด์ PR ์์ฑํ๋ฉด๋จ
+# ๐ฑ ๋ก๋ ๋ฏธ์
์งํ
-### ํ
์คํธ ์คํ ๊ฐ์ด๋
+## ๐ ๊ตฌํ ๊ธฐ๋ฅ ๋ชฉ๋ก
-- ํฐ๋ฏธ๋์์ `java -version`์ ์คํํ์ฌ Java ๋ฒ์ ์ด 14์ธ์ง ํ์ธํ๋ค. ๋๋ Eclipse ๋๋ IntelliJ IDEA์ ๊ฐ์ IDE์์ Java 14๋ก ์คํ๋๋์ง ํ์ธํ๋ค.
-- ํฐ๋ฏธ๋์์ Mac ๋๋ Linux ์ฌ์ฉ์์ ๊ฒฝ์ฐ `./gradlew clean test` ๋ช
๋ น์ ์คํ ํ๊ณ ,
- Windows ์ฌ์ฉ์์ ๊ฒฝ์ฐ `gradlew.bat clean test` ๋ช
๋ น์ ์คํํ ๋ ๋์ ํ๋์ง ๋ง ํ์ธ(ํ
์คํธ๋ ์คํจ).
+### 1๏ธโฃ [์
๋ ฅ] ๊ตฌ์
ํ ๋ก๋ ๊ธ์ก ์
๋ ฅ๋ฐ๊ธฐ
----
-
-## ๐ ๊ธฐ๋ฅ ์๊ตฌ ์ฌํญ
-
-๋ก๋ ๊ฒ์ ๊ธฐ๋ฅ์ ๊ตฌํํด์ผ ํ๋ค. ๋ก๋ ๊ฒ์์ ์๋์ ๊ฐ์ ๊ท์น์ผ๋ก ์งํ๋๋ค.
-
-```
-- ๋ก๋ ๋ฒํธ์ ์ซ์ ๋ฒ์๋ 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์
-```
+- ์ฒ์ ๋จ์๋ก ์
๋ ฅ๋ฐ์ *MyLottoData*์ *money*์ ๊ธ์ก์ ์ ์ฅํฉ๋๋ค.
+- ์์ธ์ฒ๋ฆฌ
+- **inputPurchasingMoney()**: void
-- ๋ก๋ ๊ตฌ์
๊ธ์ก์ ์
๋ ฅํ๋ฉด ๊ตฌ์
๊ธ์ก์ ํด๋นํ๋ ๋งํผ ๋ก๋๋ฅผ ๋ฐํํด์ผ ํ๋ค.
-- ๋ก๋ 1์ฅ์ ๊ฐ๊ฒฉ์ 1,000์์ด๋ค.
-- ๋น์ฒจ ๋ฒํธ์ ๋ณด๋์ค ๋ฒํธ๋ฅผ ์
๋ ฅ๋ฐ๋๋ค.
-- ์ฌ์ฉ์๊ฐ ๊ตฌ๋งคํ ๋ก๋ ๋ฒํธ์ ๋น์ฒจ ๋ฒํธ๋ฅผ ๋น๊ตํ์ฌ ๋น์ฒจ ๋ด์ญ ๋ฐ ์์ต๋ฅ ์ ์ถ๋ ฅํ๊ณ ๋ก๋ ๊ฒ์์ ์ข
๋ฃํ๋ค.
-- ์ฌ์ฉ์๊ฐ ์๋ชป๋ ๊ฐ์ ์
๋ ฅํ ๊ฒฝ์ฐ `IllegalArgumentException`๋ฅผ ๋ฐ์์ํค๊ณ , "[ERROR]"๋ก ์์ํ๋ ์๋ฌ ๋ฉ์์ง๋ฅผ ์ถ๋ ฅ ํ ์ข
๋ฃํ๋ค.
-
-## โ๐ป ์
์ถ๋ ฅ ์๊ตฌ์ฌํญ
-
-### โจ๏ธ ์
๋ ฅ
-
-- ๋ก๋ ๊ตฌ์
๊ธ์ก์ ์
๋ ฅ ๋ฐ๋๋ค. ๊ตฌ์
๊ธ์ก์ 1,000์ ๋จ์๋ก ์
๋ ฅ ๋ฐ์ผ๋ฉฐ 1,000์์ผ๋ก ๋๋์ด ๋จ์ด์ง์ง ์๋ ๊ฒฝ์ฐ ์์ธ ์ฒ๋ฆฌํ๋ค.
-
-```
-14000
-```
+
-- ๋น์ฒจ ๋ฒํธ๋ฅผ ์
๋ ฅ ๋ฐ๋๋ค. ๋ฒํธ๋ ์ผํ(,)๋ฅผ ๊ธฐ์ค์ผ๋ก ๊ตฌ๋ถํ๋ค.
+### 2๏ธโฃ [๊ณ์ฐ] ๋ก๋ ๋ฐํํ๊ธฐ
-```
-1,2,3,4,5,6
-```
+- ๊ตฌ์
ํ ๋ก๋ ๊ธ์ก์ผ๋ก๋ถํฐ ๋ก๋ ๊ฐ์๋ฅผ ๊ณ์ฐํด์ ๊ฐ์๋ฅผ *MyLottoData*์ *quantity*์ ์ ์ฅํฉ๋๋ค.
+- ๊ฐ์๋งํผ ๋ก๋๋ฅผ ์ฌ๋ฌ๊ฐ ๋ฐํํด์ *MyLottoData*์ *lottoSet*์ ์ ์ฅํฉ๋๋ค.
+- **issueLottoMultiSet()**: void
-- ๋ณด๋์ค ๋ฒํธ๋ฅผ ์
๋ ฅ ๋ฐ๋๋ค.
+
-```
-7
-```
+### 2๏ธโฃ [์ถ๋ ฅ] ๊ตฌ์
ํ ๋ก๋ ์ถ๋ ฅํ๊ธฐ
-### ๐ฅ ์ถ๋ ฅ
+- *MyLottoData*์ *lottoSet*์ ์ ์ฅ๋ ๊ตฌ์
ํ ๋ก๋์ ๋ฒํธ๋ค์ ์ถ๋ ฅํฉ๋๋ค.
+- **printPurchasedLotto()**: void
-- ๋ฐํํ ๋ก๋ ์๋ ๋ฐ ๋ฒํธ๋ฅผ ์ถ๋ ฅํ๋ค. ๋ก๋ ๋ฒํธ๋ ์ค๋ฆ์ฐจ์์ผ๋ก ์ ๋ ฌํ์ฌ ๋ณด์ฌ์ค๋ค.
+
-```
-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๏ธโฃ [์
๋ ฅ] ๋น์ฒจ ๋ฒํธ์ ๋ณด๋์ค ๋ฒํธ ์
๋ ฅ๋ฐ๊ธฐ
-- ๋น์ฒจ ๋ด์ญ์ ์ถ๋ ฅํ๋ค.
+- ๋น์ฒจ ๋ฒํธ์ ๋ณด๋์ค ๋ฒํธ๋ฅผ ์
๋ ฅ๋ฐ์ *WinnerLottoData*์ ์ ์ฅํฉ๋๋ค.
+- ์์ธ์ฒ๋ฆฌ
+- **inputWinnerNumber()**: void
+- **inputBonusNumber()**: void
-```
-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%)
+### 4๏ธโฃ [๊ณ์ฐ] ๋ก๋ ๋น์ฒจ ๊ฒฐ๊ณผ ๊ณ์ฐํ๊ธฐ
-```
-์ด ์์ต๋ฅ ์ 62.5%์
๋๋ค.
-```
+- ๋ฐํํ ๋ก๋์ ๋น์ฒจ ๋ฒํธ, ๋ณด๋์ค ๋ฒํธ๋ฅผ ๋น๊ตํ์ฌ *ResultLottoData*์ ์ ์ฅํฉ๋๋ค.
+- **calculateResultLotto()**: void
+ - **countNumberOfLottoMatches(**Lotto**)**: int
+ - **isMatchWithBonusNumber(**Lotto**)**: boolean
-- ์์ธ ์ํฉ ์ ์๋ฌ ๋ฌธ๊ตฌ๋ฅผ ์ถ๋ ฅํด์ผ ํ๋ค. ๋จ, ์๋ฌ ๋ฌธ๊ตฌ๋ "[ERROR]"๋ก ์์ํด์ผ ํ๋ค.
-```
-[ERROR] ๋ก๋ ๋ฒํธ๋ 1๋ถํฐ 45 ์ฌ์ด์ ์ซ์์ฌ์ผ ํฉ๋๋ค.
-```
+
-### ๐ป ์คํ ๊ฒฐ๊ณผ ์์
+### 5๏ธโฃ [์ถ๋ ฅ] ๋ก๋ ๋น์ฒจ ๊ฒฐ๊ณผ ์ถ๋ ฅํ๊ธฐ
-```
-๊ตฌ์
๊ธ์ก์ ์
๋ ฅํด ์ฃผ์ธ์.
-8000
-
-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]
-
-๋น์ฒจ ๋ฒํธ๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์.
-1,2,3,4,5,6
-
-๋ณด๋์ค ๋ฒํธ๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์.
-7
-
-๋น์ฒจ ํต๊ณ
----
-3๊ฐ ์ผ์น (5,000์) - 1๊ฐ
-4๊ฐ ์ผ์น (50,000์) - 0๊ฐ
-5๊ฐ ์ผ์น (1,500,000์) - 0๊ฐ
-5๊ฐ ์ผ์น, ๋ณด๋์ค ๋ณผ ์ผ์น (30,000,000์) - 0๊ฐ
-6๊ฐ ์ผ์น (2,000,000,000์) - 0๊ฐ
-์ด ์์ต๋ฅ ์ 62.5%์
๋๋ค.
-```
+- *ResultLottoData*์ ์ ์ฅ๋ ๋ฐ์ดํฐ๋ฅผ ๋ฐํ์ผ๋ก ๋น์ฒจ ๊ฒฐ๊ณผ์ ์์ต๋ฅ ์ ์ถ๋ ฅํฉ๋๋ค.
+- **printResultLotto()**: void
----
-
-## ๐ฏ ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ ์ฌํญ
-
-- JDK 14 ๋ฒ์ ์์ ์คํ ๊ฐ๋ฅํด์ผ ํ๋ค.
-- ํ๋ก๊ทธ๋จ ์คํ์ ์์์ ์ `Application`์ `main()`์ด๋ค.
-- `build.gradle` ํ์ผ์ ๋ณ๊ฒฝํ ์ ์๊ณ , ์ธ๋ถ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ง ์๋๋ค.
-- [Java ์ฝ๋ ์ปจ๋ฒค์
](https://naver.github.io/hackday-conventions-java/) ๊ฐ์ด๋๋ฅผ ์ค์ํ๋ฉฐ ํ๋ก๊ทธ๋๋ฐํ๋ค.
-- ํ๋ก๊ทธ๋จ ์ข
๋ฃ ์ `System.exit()`๋ฅผ ํธ์ถํ์ง ์๋๋ค.
-- ํ๋ก๊ทธ๋จ ๊ตฌํ์ด ์๋ฃ๋๋ฉด `ApplicationTest`์ ๋ชจ๋ ํ
์คํธ๊ฐ ์ฑ๊ณตํด์ผ ํ๋ค.
-- ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ ์ฌํญ์์ ๋ฌ๋ฆฌ ๋ช
์ํ์ง ์๋ ํ ํ์ผ, ํจํค์ง ์ด๋ฆ์ ์์ ํ๊ฑฐ๋ ์ด๋ํ์ง ์๋๋ค.
-- indent(์ธ๋ดํธ, ๋ค์ฌ์ฐ๊ธฐ) depth๋ฅผ 3์ด ๋์ง ์๋๋ก ๊ตฌํํ๋ค. 2๊น์ง๋ง ํ์ฉํ๋ค.
- - ์๋ฅผ ๋ค์ด while๋ฌธ ์์ if๋ฌธ์ด ์์ผ๋ฉด ๋ค์ฌ์ฐ๊ธฐ๋ 2์ด๋ค.
- - ํํธ: indent(์ธ๋ดํธ, ๋ค์ฌ์ฐ๊ธฐ) depth๋ฅผ ์ค์ด๋ ์ข์ ๋ฐฉ๋ฒ์ ํจ์(๋๋ ๋ฉ์๋)๋ฅผ ๋ถ๋ฆฌํ๋ฉด ๋๋ค.
-- 3ํญ ์ฐ์ฐ์๋ฅผ ์ฐ์ง ์๋๋ค.
-- ํจ์(๋๋ ๋ฉ์๋)๊ฐ ํ ๊ฐ์ง ์ผ๋ง ํ๋๋ก ์ต๋ํ ์๊ฒ ๋ง๋ค์ด๋ผ.
-- JUnit 5์ AssertJ๋ฅผ ์ด์ฉํ์ฌ ๋ณธ์ธ์ด ์ ๋ฆฌํ ๊ธฐ๋ฅ ๋ชฉ๋ก์ด ์ ์ ๋์ํจ์ ํ
์คํธ ์ฝ๋๋ก ํ์ธํ๋ค.
-- ํจ์(๋๋ ๋ฉ์๋)์ ๊ธธ์ด๊ฐ 15๋ผ์ธ์ ๋์ด๊ฐ์ง ์๋๋ก ๊ตฌํํ๋ค.
- - ํจ์(๋๋ ๋ฉ์๋)๊ฐ ํ ๊ฐ์ง ์ผ๋ง ์ ํ๋๋ก ๊ตฌํํ๋ค.
-- else ์์ฝ์ด๋ฅผ ์ฐ์ง ์๋๋ค.
- - ํํธ: if ์กฐ๊ฑด์ ์์ ๊ฐ์ returnํ๋ ๋ฐฉ์์ผ๋ก ๊ตฌํํ๋ฉด else๋ฅผ ์ฌ์ฉํ์ง ์์๋ ๋๋ค.
- - else๋ฅผ ์ฐ์ง ๋ง๋ผ๊ณ ํ๋ switch/case๋ก ๊ตฌํํ๋ ๊ฒฝ์ฐ๊ฐ ์๋๋ฐ switch/case๋ ํ์ฉํ์ง ์๋๋ค.
-- Java Enum์ ์ ์ฉํ๋ค.
-- ๋๋ฉ์ธ ๋ก์ง์ ๋จ์ ํ
์คํธ๋ฅผ ๊ตฌํํด์ผ ํ๋ค. ๋จ, UI(System.out, System.in, Scanner) ๋ก์ง์ ์ ์ธํ๋ค.
- - ํต์ฌ ๋ก์ง์ ๊ตฌํํ๋ ์ฝ๋์ UI๋ฅผ ๋ด๋นํ๋ ๋ก์ง์ ๋ถ๋ฆฌํด ๊ตฌํํ๋ค.
-
-### ๋ผ์ด๋ธ๋ฌ๋ฆฌ
-
-- [`camp.nextstep.edu.missionutils`](https://github.com/woowacourse-projects/mission-utils)์์ ์ ๊ณตํ๋ `Randoms` ๋ฐ `Console` API๋ฅผ ์ฌ์ฉํ์ฌ ๊ตฌํํด์ผ ํ๋ค.
- - Random ๊ฐ ์ถ์ถ์ `camp.nextstep.edu.missionutils.Randoms`์ `pickUniqueNumbersInRange()`๋ฅผ ํ์ฉํ๋ค.
- - ์ฌ์ฉ์๊ฐ ์
๋ ฅํ๋ ๊ฐ์ `camp.nextstep.edu.missionutils.Console`์ `readLine()`์ ํ์ฉํ๋ค.
-
-#### ์ฌ์ฉ ์์
-
-```java
-List numbers = Randoms.pickUniqueNumbersInRange(1, 45, 6);
-```
+
-### Lotto ํด๋์ค
+------
-- ์ ๊ณต๋ `Lotto` ํด๋์ค๋ฅผ ํ์ฉํด ๊ตฌํํด์ผ ํ๋ค.
-- `Lotto`์ ๋งค๊ฐ ๋ณ์๊ฐ ์๋ ์์ฑ์๋ฅผ ์ถ๊ฐํ ์ ์๋ค.
-- `numbers`์ ์ ๊ทผ ์ ์ด์์ธ private์ ๋ณ๊ฒฝํ ์ ์๋ค.
-- `Lotto`์ ํ๋(์ธ์คํด์ค ๋ณ์)๋ฅผ ์ถ๊ฐํ ์ ์๋ค.
-- `Lotto`์ ํจํค์ง ๋ณ๊ฒฝ์ ๊ฐ๋ฅํ๋ค.
+
-```java
-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();
- }
- }
+## ๐ ํด๋๋ง
+
+```
+๐ฆ src/main/java/
+|
++ ๐ lotto/
+โ
++-------๐
ฒ Application
+| : main() ์กด์ฌ, LottoManager ํธ์ถ
+|
++-------๐
ฒ LottoManager
+| : ๋ก๋๊ฐ ์งํ๋๋ ํด๋์ค
+|
++-------๐
ฒ Lotto
+| : 6๊ฐ์ ๋ก๋ ์ซ์๊ฐ ์ ์ฅ๋๋ ํด๋์ค
+|
++-------๐
ฒ MyLottoData
+| : ๊ตฌ์
๊ธ์ก๊ณผ ๋ฐํ๋ ๋ก๋ ์๋๊ณผ ๋ฒํธ๊ฐ ์ ์ฅ๋๋ ํด๋์ค
+|
++-------๐
ฒ WinnerLottoData
+| : ๋น์ฒจ ๋ฒํธ์ ๋ณด๋์ค ๋ฒํธ๊ฐ ์ ์ฅ๋๋ ํด๋์ค
+|
++-------๐
ฒ ResultLottoData
+| : ๋ก๋ ๋น์ฒจ ๊ฒฐ๊ณผ์ ์์ต๋ฅ ์ด ์ ์ฅ๋๋ ํด๋์ค
+|
++-------๐
ฒ Message
+| : ์์ ๋ฉ์ธ์ง๋ค์ ๋ชจ์๋์ ํด๋์ค
+|
++-------๐
ฒ Number
+| : ์์ ์ซ์๋ค์ ๋ชจ์๋์ ํด๋์ค
- // TODO: ์ถ๊ฐ ๊ธฐ๋ฅ ๊ตฌํ
-}
```
diff --git a/build.gradle b/build.gradle
index 1cd662974c..d844da4369 100644
--- a/build.gradle
+++ b/build.gradle
@@ -13,7 +13,7 @@ dependencies {
java {
toolchain {
- languageVersion = JavaLanguageVersion.of(14)
+ languageVersion = JavaLanguageVersion.of(15)
}
}
diff --git a/src/main/java/lotto/Application.java b/src/main/java/lotto/Application.java
index 367ee30584..de3822f8d5 100644
--- a/src/main/java/lotto/Application.java
+++ b/src/main/java/lotto/Application.java
@@ -2,6 +2,8 @@
public class Application {
public static void main(String[] args) {
- // TODO: ํ๋ก๊ทธ๋จ ๊ตฌํ
+ LottoManager lottoManager = new LottoManager();
+ GameController game = new GameController(lottoManager);
+ game.play();
}
}
\ No newline at end of file
diff --git a/src/main/java/lotto/GameController.java b/src/main/java/lotto/GameController.java
new file mode 100644
index 0000000000..de6d002f9f
--- /dev/null
+++ b/src/main/java/lotto/GameController.java
@@ -0,0 +1,90 @@
+package lotto;
+
+import camp.nextstep.edu.missionutils.Console;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class GameController {
+
+ private final LottoManager lottoManager;
+
+ public GameController(LottoManager lottoManager) {
+ this.lottoManager = lottoManager;
+ }
+
+ public void play() {
+ System.out.println(Message.Input.PURCHASE_MONEY);
+ int money = readMoney();
+
+ int quantity = money / Number.Rule.PRICE.toNumber();
+ List myLottoSet = new ArrayList<>();
+ for (int i = 0; i < quantity; i++) {
+ Lotto lottoOneSet = lottoManager.generate(Number.Rule.MIN.toNumber(),
+ Number.Rule.MAX.toNumber(), Number.Rule.SIZE.toNumber());
+ myLottoSet.add(lottoOneSet);
+ }
+
+ System.out.println(Message.Output.PURCHASE_QUANTITY.toQuantityFormat(quantity));
+ for (Lotto lotto : myLottoSet) {
+ System.out.println(lotto.getNumbers());
+ }
+
+ System.out.println(Message.Input.WINNER_NUMBER);
+ Lotto winnerNumber = readNumber();
+ int bonusNumber = readBonus();
+
+ Score score = lottoManager.calculate(myLottoSet, winnerNumber, bonusNumber);
+ double rate = score.calculateRate(money);
+ System.out.println(Message.Output.RESULT_STAT);
+ System.out.println(score);
+ System.out.println(Message.Output.RESULT_RATE.toRateFormat(rate));
+ }
+
+ private int readMoney() {
+ String input = Console.readLine();
+ for (char c : input.toCharArray()) {
+ if (c < '0' || c > '9') {
+ throw new IllegalArgumentException(Message.Error.PURCHASE_AMOUNT.toString());
+ }
+ }
+ int purchaseMoney = Integer.parseInt(input);
+ if (purchaseMoney % Number.Rule.PRICE.toNumber() != 0) {
+ throw new IllegalArgumentException(Message.Error.PURCHASE_AMOUNT.toString());
+ }
+ return Integer.parseInt(input);
+ }
+
+ private Lotto readNumber() {
+ String input = Console.readLine();
+ try {
+ String[] stringArray = input.split(",");
+ for (String str : stringArray) {
+ int num = Integer.parseInt(str);
+ }
+ } catch (Exception e) {
+ throw new IllegalArgumentException(Message.Error.LOTTO_NUMBER.toString());
+ }
+ String[] stringArray = input.split(",");
+ List integerList = new ArrayList<>();
+ for (String str : stringArray) {
+ int num = Integer.parseInt(str);
+ integerList.add(num);
+ }
+ return new Lotto(integerList);
+ }
+
+ private int readBonus() {
+ String input = Console.readLine();
+ try {
+ Integer.parseInt(input);
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException(Message.Error.BONUS_NUMBER.toString());
+ }
+ int bonusNumber = Integer.parseInt(input);
+ if (bonusNumber < Number.Rule.MIN.toNumber() || bonusNumber > Number.Rule.MAX.toNumber()) {
+ throw new IllegalArgumentException(Message.Error.BONUS_NUMBER.toString());
+ }
+ return bonusNumber;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/lotto/Lotto.java b/src/main/java/lotto/Lotto.java
new file mode 100644
index 0000000000..96f98c68c3
--- /dev/null
+++ b/src/main/java/lotto/Lotto.java
@@ -0,0 +1,26 @@
+package lotto;
+
+import camp.nextstep.edu.missionutils.Randoms;
+
+import java.util.Collections;
+import java.util.ArrayList;
+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();
+ }
+ }
+
+ public List getNumbers() {
+ return numbers;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/lotto/LottoManager.java b/src/main/java/lotto/LottoManager.java
new file mode 100644
index 0000000000..a0dec31427
--- /dev/null
+++ b/src/main/java/lotto/LottoManager.java
@@ -0,0 +1,56 @@
+package lotto;
+
+import camp.nextstep.edu.missionutils.Randoms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class LottoManager {
+ public Lotto generate(int min, int max, int size) {
+ List lottoOneList = Randoms.pickUniqueNumbersInRange(min, max, size);
+ return new Lotto(lottoOneList);
+ }
+
+ public Score calculate(List myLottoSet, Lotto winnerLotto, int bonusNumber) {
+ int threeMatchCount = 0;
+ int fourMatchCount = 0;
+ int fiveMatchCount = 0;
+ int fiveAndBonusMatchCount = 0;
+ int sixMatchCount = 0;
+ for (Lotto myLottoOneSet : myLottoSet) {
+ int matchCount = countNumberOfLottoMatches(myLottoOneSet, winnerLotto);
+ boolean isBonusMatch = myLottoOneSet.getNumbers().contains(bonusNumber);
+ if (matchCount == 3) {
+ threeMatchCount++;
+ continue;
+ }
+ if (matchCount == 4) {
+ fourMatchCount++;
+ continue;
+ }
+ if (matchCount == 5) {
+ if (isBonusMatch) {
+ fiveAndBonusMatchCount++;
+ continue;
+ }
+ fiveMatchCount++;
+ continue;
+ }
+ if (matchCount == 6) {
+ sixMatchCount++;
+ }
+ }
+ return new Score(threeMatchCount, fourMatchCount,
+ fiveMatchCount, fiveAndBonusMatchCount, sixMatchCount);
+ }
+
+ private int countNumberOfLottoMatches(Lotto myLottoOneSet, Lotto winnerLotto) {
+ int matchCount = 0;
+ for (int number : myLottoOneSet.getNumbers()) {
+ if (winnerLotto.getNumbers().contains(number)) {
+ matchCount++;
+ }
+ }
+ return matchCount;
+ }
+}
diff --git a/src/main/java/lotto/Message.java b/src/main/java/lotto/Message.java
new file mode 100644
index 0000000000..76d44b903b
--- /dev/null
+++ b/src/main/java/lotto/Message.java
@@ -0,0 +1,72 @@
+package lotto;
+
+import java.text.DecimalFormat;
+
+public class Message {
+ public enum Input {
+ PURCHASE_MONEY("๊ตฌ์
๊ธ์ก์ ์
๋ ฅํด ์ฃผ์ธ์."),
+ WINNER_NUMBER("\n๋น์ฒจ ๋ฒํธ๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์."),
+ BONUS_NUMBER("\n๋ณด๋์ค ๋ฒํธ๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์.");
+
+ private final String inputMessage;
+
+ Input(String message) {
+ inputMessage = message;
+ }
+
+ @Override
+ public String toString() {
+ return inputMessage;
+ }
+ }
+
+ public enum Output {
+ PURCHASE_QUANTITY("\n%d๊ฐ๋ฅผ ๊ตฌ๋งคํ์ต๋๋ค."),
+ RESULT_STAT("\n๋น์ฒจ ํต๊ณ\n---"),
+ RESULT_RATE("์ด ์์ต๋ฅ ์ %s%%์
๋๋ค."),
+ RESULT_CONTENTS("""
+ 3๊ฐ ์ผ์น (%s์) - %d๊ฐ
+ 4๊ฐ ์ผ์น (%s์) - %d๊ฐ
+ 5๊ฐ ์ผ์น (%s์) - %d๊ฐ
+ 5๊ฐ ์ผ์น, ๋ณด๋์ค ๋ณผ ์ผ์น (%s์) - %d๊ฐ
+ 6๊ฐ ์ผ์น (%s์) - %d๊ฐ""");
+
+ private final String outputMessage;
+
+ Output(String message) {
+ outputMessage = message;
+ }
+
+ public String toQuantityFormat(int lottoQuantity) {
+ return String.format(outputMessage, lottoQuantity);
+ }
+
+ public String toRateFormat(double rate) {
+ DecimalFormat decimalFormat = new DecimalFormat("#.##");
+ String roundedNumber = decimalFormat.format(rate);
+ return String.format(outputMessage, roundedNumber);
+ }
+
+ @Override
+ public String toString() {
+ return outputMessage;
+ }
+ }
+
+ public enum Error {
+ PURCHASE_AMOUNT("๊ตฌ์
๊ธ์ก์ ๋ก๋ ํ์ฅ ๊ฐ๊ฒฉ์ ๋จ์๋ก ์
๋ ฅํด์ฃผ์ธ์."),
+ LOTTO_NUMBER("๋ก๋ ๋ฒํธ๋ ์ค๋ณต๋์ง ์๋ 1๋ถํฐ 45 ์ฌ์ด์ ์ซ์์ฌ์ผ ํฉ๋๋ค."),
+ BONUS_NUMBER("์ค๋ณต๋์ง ์๋ ํ ๊ฐ์ ๋ณด๋์ค ๋ฒํธ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.");
+
+ private final String errorMessage;
+
+ Error(String input) {
+ this.errorMessage = input;
+ }
+
+ @Override
+ public String toString() {
+ return "[ERROR] " + errorMessage;
+ }
+ }
+}
diff --git a/src/main/java/lotto/Number.java b/src/main/java/lotto/Number.java
new file mode 100644
index 0000000000..e28a21cc3a
--- /dev/null
+++ b/src/main/java/lotto/Number.java
@@ -0,0 +1,46 @@
+package lotto;
+
+import java.text.DecimalFormat;
+
+public class Number {
+ public enum Rule {
+ MIN(1),
+ MAX(45),
+ SIZE(6),
+ PRICE(1000);
+
+ private final int rule;
+
+ Rule(int number) {
+ this.rule = number;
+ }
+
+ public int toNumber() {
+ return rule;
+ }
+ }
+
+ public enum Prize {
+ THREE_MATCH(5000),
+ FOUR_MATCH(50000),
+ FIVE_MATCH(1500000),
+ FIVE_BONUS_MATCH(30000000),
+ SIX_MATCH(2000000000);
+
+ private final int prize;
+
+ Prize(int number) {
+ this.prize = number;
+ }
+
+ public int toNumber() {
+ return prize;
+ }
+
+ public String toDecimalFormat() {
+ DecimalFormat decimalFormat = new DecimalFormat("#,###");
+ String formattedNumber = decimalFormat.format(prize);
+ return formattedNumber;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/lotto/Score.java b/src/main/java/lotto/Score.java
new file mode 100644
index 0000000000..4b49a835f4
--- /dev/null
+++ b/src/main/java/lotto/Score.java
@@ -0,0 +1,35 @@
+package lotto;
+
+public class Score {
+ private final int threeMatchCount, fourMatchCount,
+ fiveMatchCount, fiveAndBonusMatchCount, sixMatchCount;
+
+ public Score(int threeMatchCount, int fourMatchCount,
+ int fiveMatchCount, int fiveAndBonusMatchCount, int sixMatchCount) {
+ this.threeMatchCount = threeMatchCount;
+ this.fourMatchCount = fourMatchCount;
+ this.fiveMatchCount = fiveMatchCount;
+ this.fiveAndBonusMatchCount = fiveAndBonusMatchCount;
+ this.sixMatchCount = sixMatchCount;
+ }
+
+ public double calculateRate(int purchaseMoney) {
+ double money = purchaseMoney;
+ int totalProfit = threeMatchCount * Number.Prize.THREE_MATCH.toNumber()
+ + fourMatchCount * Number.Prize.FOUR_MATCH.toNumber()
+ + fiveMatchCount * Number.Prize.FIVE_MATCH.toNumber()
+ + fiveAndBonusMatchCount * Number.Prize.FIVE_BONUS_MATCH.toNumber()
+ + sixMatchCount * Number.Prize.SIX_MATCH.toNumber();
+ return (totalProfit / money) * 100.0;
+ }
+
+ @Override
+ public String toString() {
+ return String.format(Message.Output.RESULT_CONTENTS.toString(),
+ Number.Prize.THREE_MATCH.toDecimalFormat(), threeMatchCount,
+ Number.Prize.FOUR_MATCH.toDecimalFormat(), fourMatchCount,
+ Number.Prize.FIVE_MATCH.toDecimalFormat(), fiveMatchCount,
+ Number.Prize.FIVE_BONUS_MATCH.toDecimalFormat(), fiveAndBonusMatchCount,
+ Number.Prize.SIX_MATCH.toDecimalFormat(), sixMatchCount);
+ }
+}