diff --git a/README.md b/README.md
index aff2c46597..e46f540817 100644
--- a/README.md
+++ b/README.md
@@ -1,239 +1,60 @@
# ๋ฏธ์
- ๋ก๋
-## ๐ ์งํ ๋ฐฉ์
+## โ๏ธ ๊ตฌํํ ๊ธฐ๋ฅ ๋ชฉ๋ก
-- ๋ฏธ์
์ **๊ธฐ๋ฅ ์๊ตฌ ์ฌํญ, ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ ์ฌํญ, ๊ณผ์ ์งํ ์๊ตฌ ์ฌํญ** ์ธ ๊ฐ์ง๋ก ๊ตฌ์ฑ๋์ด ์๋ค.
-- ์ธ ๊ฐ์ ์๊ตฌ ์ฌํญ์ ๋ง์กฑํ๊ธฐ ์ํด ๋
ธ๋ ฅํ๋ค. ํนํ ๊ธฐ๋ฅ์ ๊ตฌํํ๊ธฐ ์ ์ ๊ธฐ๋ฅ ๋ชฉ๋ก์ ๋ง๋ค๊ณ , ๊ธฐ๋ฅ ๋จ์๋ก ์ปค๋ฐ ํ๋ ๋ฐฉ์์ผ๋ก ์งํํ๋ค.
-- ๊ธฐ๋ฅ ์๊ตฌ ์ฌํญ์ ๊ธฐ์ฌ๋์ง ์์ ๋ด์ฉ์ ์ค์ค๋ก ํ๋จํ์ฌ ๊ตฌํํ๋ค.
+### `App.js`์ `play` ๋ฉ์๋๋ฅผ ํตํด ํ๋ก๊ทธ๋จ ์์
-## ๐ฎ ๋ฏธ์
์ ์ถ ๋ฐฉ๋ฒ
+- [x] play ๋ฉ์๋ ์์ฑ
-- ๋ฏธ์
๊ตฌํ์ ์๋ฃํ ํ GitHub์ ํตํด ์ ์ถํด์ผ ํ๋ค.
- - GitHub์ ํ์ฉํ ์ ์ถ ๋ฐฉ๋ฒ์ [ํ๋ฆฌ์ฝ์ค ๊ณผ์ ์ ์ถ](https://github.com/woowacourse/woowacourse-docs/tree/master/precourse) ๋ฌธ์๋ฅผ ์ฐธ๊ณ ํด
- ์ ์ถํ๋ค.
-- GitHub์ ๋ฏธ์
์ ์ ์ถํ ํ [์ฐ์ํํ
ํฌ์ฝ์ค ์ง์](https://apply.techcourse.co.kr) ์ฌ์ดํธ์ ์ ์ํ์ฌ ํ๋ฆฌ์ฝ์ค ๊ณผ์ ๋ฅผ ์ ์ถํ๋ค.
- - ์์ธํ ๋ฐฉ๋ฒ์ [์ ์ถ ๊ฐ์ด๋](https://github.com/woowacourse/woowacourse-docs/tree/master/precourse#์ ์ถ-๊ฐ์ด๋) ์ฐธ๊ณ
- - **Pull Request๋ง ๋ณด๋ด๊ณ ์ง์ ํ๋ซํผ์์ ๊ณผ์ ๋ฅผ ์ ์ถํ์ง ์์ผ๋ฉด ์ต์ข
์ ์ถํ์ง ์์ ๊ฒ์ผ๋ก ์ฒ๋ฆฌ๋๋ ์ฃผ์ํ๋ค.**
+### ๋ก๋ ๋ก์ง
-## ๐จ ๊ณผ์ ์ ์ถ ์ ์ฒดํฌ ๋ฆฌ์คํธ - 0์ ๋ฐฉ์ง
+- [x] ๋ก๋ ๊ตฌ์
๊ธ์ก ์
๋ ฅ
-- ๊ธฐ๋ฅ ๊ตฌํ์ ๋ชจ๋ ์ ์์ ์ผ๋ก ํ๋๋ผ๋ **์๊ตฌ ์ฌํญ์ ๋ช
์๋ ์ถ๋ ฅ๊ฐ ํ์์ ์งํค์ง ์์ ๊ฒฝ์ฐ 0์ ์ผ๋ก ์ฒ๋ฆฌ**ํ๋ค.
-- ๊ธฐ๋ฅ ๊ตฌํ์ ์๋ฃํ ๋ค ์๋ ๊ฐ์ด๋์ ๋ฐ๋ผ ํ
์คํธ๋ฅผ ์คํํ์ ๋ ๋ชจ๋ ํ
์คํธ๊ฐ ์ฑ๊ณตํ๋์ง ํ์ธํ๋ค.
-- **ํ
์คํธ๊ฐ ์คํจํ ๊ฒฝ์ฐ 0์ ์ผ๋ก ์ฒ๋ฆฌ**๋๋ฏ๋ก, ๋ฐ๋์ ํ์ธ ํ ์ ์ถํ๋ค.
+ - ๊ตฌ์
๊ธ์ก ์
๋ ฅ ์๋ด ๋ฌธ๊ตฌ ์ถ๋ ฅ
+ `๊ตฌ์
๊ธ์ก์ ์
๋ ฅํด ์ฃผ์ธ์.`
-### ํ
์คํธ ์คํ ๊ฐ์ด๋
+ - ์๋ชป๋ ๊ฐ ์
๋ ฅ ์ **throw๋ฌธ์ ํตํด ์์ธ ๋ฐ์ ๋ฐ ์ ํ๋ฆฌ์ผ์ด์
์ข
๋ฃ**
+ - 1,000์์ผ๋ก ๋๋์ด ๋จ์ด์ง์ง ์๋ ๊ฒฝ์ฐ
-- ํ
์คํธ ํจํค์ง ์ค์น๋ฅผ ์ํด `Node.js` ๋ฒ์ `18.17.1` ์ด์์ด ํ์ํ๋ค.
-- ๋ค์ ๋ช
๋ น์ด๋ฅผ ์
๋ ฅํด ํจํค์ง๋ฅผ ์ค์นํ๋ค.
+- [x] ๊ตฌ์
๊ธ์ก์ ํด๋นํ๋ ๋งํผ ๋ก๋ ๋ฐํ(๋ก๋ 1์ฅ ๋น 1,000์)
-```bash
-npm install
-```
+ - ๊ตฌ๋งค ๊ฐฏ์ ๋ฌธ๊ตฌ ์ถ๋ ฅ
+ `${๋ก๋ ๊ตฌ์
๊ธ์ก/1000}๊ฐ๋ฅผ ๊ตฌ๋งคํ์ต๋๋ค.`
-- ์ค์น๊ฐ ์๋ฃ๋์๋ค๋ฉด, ๋ค์ ๋ช
๋ น์ด๋ฅผ ์
๋ ฅํด ํ
์คํธ๋ฅผ ์คํํ๋ค.
+ - ๊ฐ ๋ก๋ ๋ฒํธ ์ถ๋ ฅ(๊ตฌ๋งค ๊ฐฏ์ ๋งํผ)
+ - `Random API`๋ฅผ ์ด์ฉํ์ฌ 1-45 ์ฌ์ด ๊ฐ 6๊ฐ ์ ํ
+ - ๋ก๋ ๋ฒํธ๋ ์ค๋ฆ์ฐจ์์ผ๋ก ์ ๋ ฌํ์ฌ ๋ณด์ฌ์ค๋ค.
-```bash
-npm test
-```
+- [x] ๋น์ฒจ ๋ฒํธ ์
๋ ฅ
----
+ - ๋น์ฒจ ๋ฒํธ ์
๋ ฅ ์๋ด ๋ฌธ๊ตฌ ์ถ๋ ฅ
+ `๋น์ฒจ ๋ฒํธ๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์.`
-## ๐ ๊ธฐ๋ฅ ์๊ตฌ ์ฌํญ
+ - ์๋ชป๋ ๊ฐ ์
๋ ฅ ์ **throw๋ฌธ์ ํตํด ์์ธ ๋ฐ์ ๋ฐ ์ ํ๋ฆฌ์ผ์ด์
์ข
๋ฃ**
+ - ์ผํ๋ก ๊ตฌ๋ถํ์ ๋, ๋ฒํธ 6๊ฐ
+ - ๊ฐ ๋ฒํธ๊ฐ 1-45 ๋ฒ์ ๋ด์ ์๊ฐ ์๋ ๊ฒฝ์ฐ
-- ๋ก๋ ๊ฒ์ ๊ธฐ๋ฅ์ ๊ตฌํํด์ผ ํ๋ค. ๋ก๋ ๊ฒ์์ ์๋์ ๊ฐ์ ๊ท์น์ผ๋ก ์งํ๋๋ค.
+- [x] ๋ณด๋์ค ๋ฒํธ ์
๋ ฅ
-```
-- ๋ก๋ ๋ฒํธ์ ์ซ์ ๋ฒ์๋ 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์์ด๋ค.
-- ๋น์ฒจ ๋ฒํธ์ ๋ณด๋์ค ๋ฒํธ๋ฅผ ์
๋ ฅ๋ฐ๋๋ค.
-- ์ฌ์ฉ์๊ฐ ๊ตฌ๋งคํ ๋ก๋ ๋ฒํธ์ ๋น์ฒจ ๋ฒํธ๋ฅผ ๋น๊ตํ์ฌ ๋น์ฒจ ๋ด์ญ ๋ฐ ์์ต๋ฅ ์ ์ถ๋ ฅํ๊ณ ๋ก๋ ๊ฒ์์ ์ข
๋ฃํ๋ค.
-- ์ฌ์ฉ์๊ฐ ์๋ชป๋ ๊ฐ์ ์
๋ ฅํ ๊ฒฝ์ฐ `throw`๋ฌธ์ ์ฌ์ฉํด ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค. ๊ทธ๋ฐ ๋ค์, "[ERROR]"๋ก ์์ํ๋ ์๋ฌ ๋ฉ์์ง๋ฅผ ์ถ๋ ฅํ๊ณ ํด๋น ๋ถ๋ถ๋ถํฐ ์
๋ ฅ์ ๋ค์ ๋ฐ๋๋ค.
- ```
- ์์) [ERROR] ์ซ์๊ฐ ์๋ชป๋ ํ์์
๋๋ค.
- ```
-
-### ์
์ถ๋ ฅ ์๊ตฌ ์ฌํญ
-
-#### ์
๋ ฅ
-
-- ๋ก๋ ๊ตฌ์
๊ธ์ก์ ์
๋ ฅ ๋ฐ๋๋ค. ๊ตฌ์
๊ธ์ก์ 1,000์ ๋จ์๋ก ์
๋ ฅ ๋ฐ์ผ๋ฉฐ 1,000์์ผ๋ก ๋๋์ด ๋จ์ด์ง์ง ์๋ ๊ฒฝ์ฐ ์์ธ ์ฒ๋ฆฌํ๋ค.
-
-```
-14000
-```
-
-- ๋น์ฒจ ๋ฒํธ๋ฅผ ์
๋ ฅ ๋ฐ๋๋ค. ๋ฒํธ๋ ์ผํ(,)๋ฅผ ๊ธฐ์ค์ผ๋ก ๊ตฌ๋ถํ๋ค.
-
-```
-1,2,3,4,5,6
-```
-
-- ๋ณด๋์ค ๋ฒํธ๋ฅผ ์
๋ ฅ ๋ฐ๋๋ค.
-
-```
-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๊ฐ
-```
+ - ์๋ชป๋ ๊ฐ ์
๋ ฅ ์ **throw๋ฌธ์ ํตํด ์์ธ ๋ฐ์ ๋ฐ ์ ํ๋ฆฌ์ผ์ด์
์ข
๋ฃ**
+ - ๋ฒํธ๊ฐ 1-45 ๋ฒ์ ๋ด์ ์๊ฐ ์๋ ๊ฒฝ์ฐ
-- ์์ต๋ฅ ์ ์์์ ๋์งธ ์๋ฆฌ์์ ๋ฐ์ฌ๋ฆผํ๋ค. (ex. 100.0%, 51.5%, 1,000,000.0%)
+- [x] ๋ก๋ ๊ฒฐ๊ณผ ์ถ๋ ฅ
-```
-์ด ์์ต๋ฅ ์ 62.5%์
๋๋ค.
-```
+ - ๋น์ฒจ ๋ด์ญ ์ถ๋ ฅ
+ - ์์ต๋ฅ ์ ์์์ ๋์งธ ์๋ฆฌ์์ ๋ฐ์ฌ๋ฆผ
+ - ์๋๋ ์์์ด๋ค.
-- ์์ธ ์ํฉ ์ ์๋ฌ ๋ฌธ๊ตฌ๋ฅผ ์ถ๋ ฅํด์ผ ํ๋ค. ๋จ, ์๋ฌ ๋ฌธ๊ตฌ๋ "[ERROR]"๋ก ์์ํด์ผ ํ๋ค.
-
-```
-[ERROR] ๋ก๋ ๋ฒํธ๋ 1๋ถํฐ 45 ์ฌ์ด์ ์ซ์์ฌ์ผ ํฉ๋๋ค.
-```
-
-#### ์คํ ๊ฒฐ๊ณผ ์์
-
-```
-๊ตฌ์
๊ธ์ก์ ์
๋ ฅํด ์ฃผ์ธ์.
-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%์
๋๋ค.
-```
-
----
-
-## ๐ฏ ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ ์ฌํญ
-
-- Node.js 18.17.1 ๋ฒ์ ์์ ์คํ ๊ฐ๋ฅํด์ผ ํ๋ค. **Node.js 18.17.1์์ ์ ์์ ์ผ๋ก ๋์ํ์ง ์์ ๊ฒฝ์ฐ 0์ ์ฒ๋ฆฌํ๋ค.**
-- ํ๋ก๊ทธ๋จ ์คํ์ ์์์ ์ `App.js`์ `play` ๋ฉ์๋์ด๋ค. ์๋์ ๊ฐ์ด ํ๋ก๊ทธ๋จ์ ์คํ์ํฌ ์ ์์ด์ผ ํ๋ค.
-
-**์์**
-
-```javascript
-const app = new App();
-app.play();
-```
-
-- `package.json`์ ๋ณ๊ฒฝํ ์ ์๊ณ ์ธ๋ถ ๋ผ์ด๋ธ๋ฌ๋ฆฌ(jQuery, Lodash ๋ฑ)๋ฅผ ์ฌ์ฉํ์ง ์๋๋ค. ์์ Vanilla JS๋ก๋ง ๊ตฌํํ๋ค.
-- [JavaScript ์ฝ๋ ์ปจ๋ฒค์
](https://github.com/woowacourse/woowacourse-docs/tree/main/styleguide/javascript)์ ์งํค๋ฉด์ ํ๋ก๊ทธ๋๋ฐ ํ๋ค
-- ํ๋ก๊ทธ๋จ ์ข
๋ฃ ์ `process.exit()`๋ฅผ ํธ์ถํ์ง ์๋๋ค.
-- ํ๋ก๊ทธ๋จ ๊ตฌํ์ด ์๋ฃ๋๋ฉด `ApplicationTest`์ ๋ชจ๋ ํ
์คํธ๊ฐ ์ฑ๊ณตํด์ผ ํ๋ค. **ํ
์คํธ๊ฐ ์คํจํ ๊ฒฝ์ฐ 0์ ์ฒ๋ฆฌํ๋ค.**
-- ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ ์ฌํญ์์ ๋ฌ๋ฆฌ ๋ช
์ํ์ง ์๋ ํ ํ์ผ, ํจํค์ง ์ด๋ฆ์ ์์ ํ๊ฑฐ๋ ์ด๋ํ์ง ์๋๋ค.
-- indent(์ธ๋ดํธ, ๋ค์ฌ์ฐ๊ธฐ) depth๋ฅผ 3์ด ๋์ง ์๋๋ก ๊ตฌํํ๋ค. 2๊น์ง๋ง ํ์ฉํ๋ค.
- - ์๋ฅผ ๋ค์ด while๋ฌธ ์์ if๋ฌธ์ด ์์ผ๋ฉด ๋ค์ฌ์ฐ๊ธฐ๋ 2์ด๋ค.
- - ํํธ: indent(์ธ๋ดํธ, ๋ค์ฌ์ฐ๊ธฐ) depth๋ฅผ ์ค์ด๋ ์ข์ ๋ฐฉ๋ฒ์ ํจ์(๋๋ ๋ฉ์๋)๋ฅผ ๋ถ๋ฆฌํ๋ฉด ๋๋ค.
-- ํจ์(๋๋ ๋ฉ์๋)๊ฐ ํ ๊ฐ์ง ์ผ๋ง ํ๋๋ก ์ต๋ํ ์๊ฒ ๋ง๋ค์ด๋ผ.
-- Jest๋ฅผ ์ด์ฉํ์ฌ ๋ณธ์ธ์ด ์ ๋ฆฌํ ๊ธฐ๋ฅ ๋ชฉ๋ก์ด ์ ์ ๋์ํจ์ ํ
์คํธ ์ฝ๋๋ก ํ์ธํ๋ค.
-
-### ์ถ๊ฐ๋ ์๊ตฌ ์ฌํญ
-
-- ํจ์(๋๋ ๋ฉ์๋)์ ๊ธธ์ด๊ฐ 15๋ผ์ธ์ ๋์ด๊ฐ์ง ์๋๋ก ๊ตฌํํ๋ค.
- - ํจ์(๋๋ ๋ฉ์๋)๊ฐ ํ ๊ฐ์ง ์ผ๋ง ์ ํ๋๋ก ๊ตฌํํ๋ค.
-- else๋ฅผ ์ง์ํ๋ค.
- - ํํธ: if ์กฐ๊ฑด์ ์์ ๊ฐ์ returnํ๋ ๋ฐฉ์์ผ๋ก ๊ตฌํํ๋ฉด else๋ฅผ ์ฌ์ฉํ์ง ์์๋ ๋๋ค.
- - ๋๋ก๋ if/else, switch๋ฌธ์ ์ฌ์ฉํ๋ ๊ฒ์ด ๋ ๊น๋ํด ๋ณด์ผ ์ ์๋ค. ์ด๋ ๊ฒฝ์ฐ์ ์ฐ๋ ๊ฒ์ด ์ ์ ํ ์ง ์ค์ค๋ก ๊ณ ๋ฏผํด ๋ณธ๋ค.
-- ๋๋ฉ์ธ ๋ก์ง์ ๋จ์ ํ
์คํธ๋ฅผ ๊ตฌํํด์ผ ํ๋ค. ๋จ, UI(Console.readLineAsync, Console.print) ๋ก์ง์ ๋ํ ๋จ์ ํ
์คํธ๋ ์ ์ธํ๋ค.
- - ํต์ฌ ๋ก์ง์ ๊ตฌํํ๋ ์ฝ๋์ UI๋ฅผ ๋ด๋นํ๋ ๋ก์ง์ ๊ตฌ๋ถํ๋ค.
- - ๋จ์ ํ
์คํธ ์์ฑ์ด ์ต์ํ์ง ์๋ค๋ฉด `__tests__/LottoTest.js`๋ฅผ ์ฐธ๊ณ ํ์ฌ ํ์ตํ ํ ํ
์คํธ๋ฅผ ๊ตฌํํ๋ค.
-
-### ๋ผ์ด๋ธ๋ฌ๋ฆฌ
-
-- `@woowacourse/mission-utils`์์ ์ ๊ณตํ๋ `Random` ๋ฐ `Console` API๋ฅผ ์ฌ์ฉํ์ฌ ๊ตฌํํด์ผ ํ๋ค.
- - Random ๊ฐ ์ถ์ถ์ `Random.pickUniqueNumbersInRange()`๋ฅผ ํ์ฉํ๋ค.
- - ์ฌ์ฉ์์ ๊ฐ์ ์
๋ ฅ ๋ฐ๊ณ ์ถ๋ ฅํ๊ธฐ ์ํด์๋ `Console.readLineAsync`, `Console.print`๋ฅผ ํ์ฉํ๋ค.
-
-#### ์ฌ์ฉ ์์
-
-```javascript
-MissionUtils.Random.pickUniqueNumbersInRange(1, 45, 6);
-```
-
-### Lotto ํด๋์ค
-
-- ์ ๊ณต๋ `Lotto` ํด๋์ค๋ฅผ ํ์ฉํด ๊ตฌํํด์ผ ํ๋ค.
-- `numbers`์ `#` prefix๋ฅผ ๋ณ๊ฒฝํ ์ ์๋ค.
-- `Lotto`์ ํ๋๋ฅผ ์ถ๊ฐํ ์ ์๋ค.
-
-```javascript
-class Lotto {
- #numbers;
-
- constructor(numbers) {
- this.#validate(numbers);
- this.#numbers = numbers;
- }
-
- #validate(numbers) {
- if (numbers.length !== 6) {
- throw new Error("[ERROR] ๋ก๋ ๋ฒํธ๋ 6๊ฐ์ฌ์ผ ํฉ๋๋ค.");
- }
- }
-
- // TODO: ์ถ๊ฐ ๊ธฐ๋ฅ ๊ตฌํ
-}
-```
-
----
-
-## โ๏ธ ๊ณผ์ ์งํ ์๊ตฌ ์ฌํญ
-
-- ๋ฏธ์
์ [javascript-lotto-6](https://github.com/woowacourse-precourse/javascript-lotto-6/) ์ ์ฅ์๋ฅผ Fork & Cloneํด ์์ํ๋ค.
-- **๊ธฐ๋ฅ์ ๊ตฌํํ๊ธฐ ์ `docs/README.md`์ ๊ตฌํํ ๊ธฐ๋ฅ ๋ชฉ๋ก์ ์ ๋ฆฌ**ํด ์ถ๊ฐํ๋ค.
-- **Git์ ์ปค๋ฐ ๋จ์๋ ์ ๋จ๊ณ์์ `docs/README.md`์ ์ ๋ฆฌํ ๊ธฐ๋ฅ ๋ชฉ๋ก ๋จ์**๋ก ์ถ๊ฐํ๋ค.
- - [์ปค๋ฐ ๋ฉ์์ง ์ปจ๋ฒค์
](https://gist.github.com/stephenparish/9941e89d80e2bc58a153) ๊ฐ์ด๋๋ฅผ ์ฐธ๊ณ ํด ์ปค๋ฐ ๋ฉ์์ง๋ฅผ ์์ฑํ๋ค.
-- ๊ณผ์ ์งํ ๋ฐ ์ ์ถ ๋ฐฉ๋ฒ์ [ํ๋ฆฌ์ฝ์ค ๊ณผ์ ์ ์ถ](https://github.com/woowacourse/woowacourse-docs/tree/master/precourse) ๋ฌธ์๋ฅผ ์ฐธ๊ณ ํ๋ค.
+ ```
+ ๋น์ฒจ ํต๊ณ
+ ---
+ 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%์
๋๋ค.
+ ```
diff --git a/__tests__/LottoTest.js b/__tests__/LottoTest.js
index 97bd457659..6642a835e2 100644
--- a/__tests__/LottoTest.js
+++ b/__tests__/LottoTest.js
@@ -1,5 +1,12 @@
+import { MissionUtils } from "@woowacourse/mission-utils";
import Lotto from "../src/Lotto.js";
+const getLogSpy = () => {
+ const logSpy = jest.spyOn(MissionUtils.Console, "print");
+ logSpy.mockClear();
+ return logSpy;
+};
+
describe("๋ก๋ ํด๋์ค ํ
์คํธ", () => {
test("๋ก๋ ๋ฒํธ์ ๊ฐ์๊ฐ 6๊ฐ๊ฐ ๋์ด๊ฐ๋ฉด ์์ธ๊ฐ ๋ฐ์ํ๋ค.", () => {
expect(() => {
@@ -7,12 +14,19 @@ describe("๋ก๋ ํด๋์ค ํ
์คํธ", () => {
}).toThrow("[ERROR]");
});
- // TODO: ์ด ํ
์คํธ๊ฐ ํต๊ณผํ ์ ์๊ฒ ๊ตฌํ ์ฝ๋ ์์ฑ
test("๋ก๋ ๋ฒํธ์ ์ค๋ณต๋ ์ซ์๊ฐ ์์ผ๋ฉด ์์ธ๊ฐ ๋ฐ์ํ๋ค.", () => {
expect(() => {
new Lotto([1, 2, 3, 4, 5, 5]);
}).toThrow("[ERROR]");
});
- // ์๋์ ์ถ๊ฐ ํ
์คํธ ์์ฑ ๊ฐ๋ฅ
+ test("๋ก๋ ๋ฒํธ๋ ์ค๋ฆ์ฐจ์์ผ๋ก ์ ๋ ฌ๋์ด ์ถ๋ ฅํด์ผ ํ๋ค.", () => {
+ const logSpy = getLogSpy();
+
+ new Lotto([5, 3, 1, 4, 2, 6]);
+
+ const log = "[1, 2, 3, 4, 5, 6]";
+
+ expect(logSpy).toHaveBeenCalledWith(expect.stringContaining(log));
+ });
});
diff --git a/src/App.js b/src/App.js
index c38b30d5b2..c964e58bb9 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,5 +1,39 @@
+import {
+ countResults,
+ getValidPurchaseAmount,
+ getWinningNumbersAndBonus,
+ printStatistics,
+ purchaseLottos,
+} from "./LottoUtils.js";
+import * as CONSTANTS from "./Constants.js";
+
class App {
- async play() {}
+ constructor() {
+ this.purchaseAmount = 0;
+ this.lottos = [];
+ this.winningResult = { winningNums: [], bonusNum: 0 };
+ this.statistics = {
+ first_prize: 0,
+ second_prize: 0,
+ third_prize: 0,
+ fourth_prize: 0,
+ fifth_prize: 0,
+ totalPrice: 0,
+ };
+ }
+ async play() {
+ this.purchaseAmount = await getValidPurchaseAmount();
+ const lottoCnt = this.purchaseAmount / CONSTANTS.LOTTO_TICKET_PRICE;
+ this.lottos = purchaseLottos(lottoCnt);
+ this.winningResult = await getWinningNumbersAndBonus();
+ this.statistics = countResults(
+ this.lottos,
+ this.winningResult.winningNums,
+ this.winningResult.bonusNum,
+ this.statistics
+ );
+ printStatistics(this.purchaseAmount, this.statistics);
+ }
}
export default App;
diff --git a/src/Constants.js b/src/Constants.js
new file mode 100644
index 0000000000..11d9383c21
--- /dev/null
+++ b/src/Constants.js
@@ -0,0 +1,30 @@
+export const ERROR_INVALID_NUMBER =
+ "[ERROR] ๊ตฌ๋งค ๊ธ์ก์ ์ ํจํ ์ซ์์ฌ์ผ ํฉ๋๋ค.";
+export const ERROR_NOT_IN_1000_UNITS =
+ "[ERROR] ๊ตฌ๋งค ๊ธ์ก์ 1,000์ ๋จ์์ด์ด์ผ ํฉ๋๋ค.";
+export const ERROR_INVALID_LOTTO_NUMBER_COUNT =
+ "[ERROR] ๋ก๋ ๋ฒํธ๋ 6๊ฐ์ฌ์ผ ํฉ๋๋ค.";
+export const ERROR_DUPLICATE_LOTTO_NUMBERS =
+ "[ERROR] ๋ก๋ ๋ฒํธ๋ ์ค๋ณต๋์ง ์์ ์ซ์๋ก ์ด๋ฃจ์ด์ ธ์ผ ํฉ๋๋ค.";
+
+export const LOTTO_PURCHASE_MESSAGE = "๊ตฌ์
๊ธ์ก์ ์
๋ ฅํด ์ฃผ์ธ์.\n";
+export const WINNING_NUMBER_INPUT_MESSAGE = "๋น์ฒจ ๋ฒํธ๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์.\n";
+export const BONUS_NUMBER_INPUT_MESSAGE = "๋ณด๋์ค ๋ฒํธ๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์.\n";
+
+export const LOTTO_STATISTICS_HEADER = "๋น์ฒจ ํต๊ณ\n---";
+export const PRIZE_3_MATCH = "3๊ฐ ์ผ์น (5,000์) - ";
+export const PRIZE_4_MATCH = "4๊ฐ ์ผ์น (50,000์) - ";
+export const PRIZE_5_MATCH = "5๊ฐ ์ผ์น (1,500,000์) - ";
+export const PRIZE_5_MATCH_WITH_BONUS =
+ "5๊ฐ ์ผ์น, ๋ณด๋์ค ๋ณผ ์ผ์น (30,000,000์) - ";
+export const PRIZE_6_MATCH = "6๊ฐ ์ผ์น (2,000,000,000์) - ";
+export const TOTAL_PROFIT_PERCENTAGE = "์ด ์์ต๋ฅ ์ ";
+
+export const LOTTO_TICKET_PRICE = 1000;
+export const LOTTO_NUMBERS_COUNT = 6;
+
+export const MATCH_3 = 5_000;
+export const MATCH_4 = 50_000;
+export const MATCH_5 = 1_500_000;
+export const MATCH_5_WITH_BONUS = 30_000_000;
+export const MATCH_6 = 2_000_000_000;
diff --git a/src/Lotto.js b/src/Lotto.js
index cb0b1527e9..2ee97f8b61 100644
--- a/src/Lotto.js
+++ b/src/Lotto.js
@@ -1,18 +1,40 @@
+import { Console } from "@woowacourse/mission-utils";
+
+import * as CONSTANTS from "./Constants.js";
+
class Lotto {
#numbers;
constructor(numbers) {
this.#validate(numbers);
- this.#numbers = numbers;
+ this.#numbers = numbers.sort((a, b) => a - b);
+ this.#printNumbers();
}
#validate(numbers) {
if (numbers.length !== 6) {
- throw new Error("[ERROR] ๋ก๋ ๋ฒํธ๋ 6๊ฐ์ฌ์ผ ํฉ๋๋ค.");
+ throw new Error(CONSTANTS.ERROR_INVALID_LOTTO_NUMBER_COUNT);
+ }
+ const uniqueNumbers = new Set(numbers);
+ if (uniqueNumbers.size !== 6) {
+ throw new Error(CONSTANTS.ERROR_DUPLICATE_LOTTO_NUMBERS);
}
}
- // TODO: ์ถ๊ฐ ๊ธฐ๋ฅ ๊ตฌํ
+ #printNumbers() {
+ Console.print(`[${this.#numbers.join(", ")}]`);
+ }
+
+ result(winningNums, bonusNum) {
+ const res = { cnt: 0, hasBonus: false };
+ for (let i = 0; i < CONSTANTS.LOTTO_NUMBERS_COUNT; i++) {
+ if (this.#numbers.includes(winningNums[i])) {
+ res.cnt++;
+ }
+ }
+ if (this.#numbers.includes(bonusNum)) res.hasBonus = true;
+ return res;
+ }
}
export default Lotto;
diff --git a/src/LottoUtils.js b/src/LottoUtils.js
new file mode 100644
index 0000000000..41c60e56be
--- /dev/null
+++ b/src/LottoUtils.js
@@ -0,0 +1,113 @@
+import { Console, Random } from "@woowacourse/mission-utils";
+import Lotto from "./Lotto.js";
+import * as CONSTANTS from "./Constants.js";
+
+export async function getValidPurchaseAmount() {
+ let validPurchaseAmount = false;
+ let purchaseAmountInput;
+
+ while (!validPurchaseAmount) {
+ try {
+ purchaseAmountInput = await Console.readLineAsync(
+ CONSTANTS.LOTTO_PURCHASE_MESSAGE
+ );
+ if (isNaN(Number(purchaseAmountInput))) {
+ throw new Error(CONSTANTS.ERROR_INVALID_NUMBER);
+ }
+
+ if (Number(purchaseAmountInput) % CONSTANTS.LOTTO_TICKET_PRICE !== 0) {
+ throw new Error(CONSTANTS.ERROR_NOT_IN_1000_UNITS);
+ }
+
+ validPurchaseAmount = true;
+ } catch (error) {
+ Console.print(error.message);
+ }
+ }
+
+ return Number(purchaseAmountInput);
+}
+
+export function purchaseLottos(count) {
+ const lottos = [];
+ Console.print(`${count}๊ฐ๋ฅผ ๊ตฌ๋งคํ์ต๋๋ค.`);
+ for (let i = 0; i < count; i++) {
+ const numbers = Random.pickUniqueNumbersInRange(
+ 1,
+ 45,
+ CONSTANTS.LOTTO_NUMBERS_COUNT
+ );
+ const lotto = new Lotto(numbers);
+ lottos.push(lotto);
+ }
+
+ return lottos;
+}
+
+export async function getWinningNumbersAndBonus() {
+ const winningNumbersInput = await Console.readLineAsync(
+ CONSTANTS.WINNING_NUMBER_INPUT_MESSAGE
+ );
+ const winningNums = winningNumbersInput
+ .split(",")
+ .map((number) => Number(number.trim()));
+ const bonusNum = await Console.readLineAsync(
+ CONSTANTS.BONUS_NUMBER_INPUT_MESSAGE
+ );
+ return { winningNums, bonusNum };
+}
+
+export function countResults(lottos, winningNums, bonusNum, statistics) {
+ const lottoCnt = lottos.length;
+ for (let i = 0; i < lottoCnt; i++) {
+ const res = lottos[i].result(winningNums, bonusNum);
+ countMatchingNum(res.cnt, statistics);
+ }
+ return statistics;
+}
+
+function countMatchingNum(cnt, statistics) {
+ switch (cnt) {
+ case 3:
+ statistics.fifth_prize++;
+ statistics.totalPrice += CONSTANTS.MATCH_3;
+ break;
+ case 4:
+ statistics.fourth_prize++;
+ statistics.totalPrice += CONSTANTS.MATCH_4;
+ break;
+ case 5:
+ if (res.hasBonus) {
+ statistics.second_prize++;
+ statistics.totalPrice += CONSTANTS.MATCH_5_WITH_BONUS;
+ break;
+ }
+ statistics.third_prize++;
+ statistics.totalPrice += CONSTANTS.MATCH_5;
+ break;
+ case 6:
+ statistics.first_prize++;
+ statistics.totalPrice += CONSTANTS.MATCH_6;
+ break;
+ default:
+ break;
+ }
+}
+
+export function printStatistics(purchaseAmount, statistics) {
+ const roundedProfitPercentage = (
+ (statistics.totalPrice / purchaseAmount) *
+ 100
+ ).toFixed(1);
+ Console.print(CONSTANTS.LOTTO_STATISTICS_HEADER);
+ Console.print(`${CONSTANTS.PRIZE_3_MATCH}${statistics.fifth_prize}๊ฐ`);
+ Console.print(`${CONSTANTS.PRIZE_4_MATCH}${statistics.fourth_prize}๊ฐ`);
+ Console.print(`${CONSTANTS.PRIZE_5_MATCH}${statistics.third_prize}๊ฐ`);
+ Console.print(
+ `${CONSTANTS.PRIZE_5_MATCH_WITH_BONUS}${statistics.second_prize}๊ฐ`
+ );
+ Console.print(`${CONSTANTS.PRIZE_6_MATCH}${statistics.first_prize}๊ฐ`);
+ Console.print(
+ `${CONSTANTS.TOTAL_PROFIT_PERCENTAGE}${roundedProfitPercentage}%์
๋๋ค.`
+ );
+}