-
Notifications
You must be signed in to change notification settings - Fork 602
[로또 게임] 김유선 미션 제출합니다. #624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
useon
wants to merge
49
commits into
woowacourse-precourse:main
Choose a base branch
from
useon:useon
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
6c9fb36
docs: 리드미에 프로그램 동작 순서를 작성한다
useon 424e6e3
docs: 리드미에 기능구현목록을 작성한다
useon 6615d42
chore: eslint, prettier를 설정한다
useon ea919a8
chore: eslint 설정을 추가한다
useon 0f55442
feat: 로또 구입 금액을 입력받는다
useon 705caa8
feat: 잘못된 구매 금액 입력시 throw 예외발생, 에러메시지출력, 재입력을 받는다
useon 7413aca
feat: 로또 구입 개수를 구하고, 개수 만큼 로또를 발행하는 기능
useon 6734fb3
feat: 로또 개수와, 로또 발행 번호를 출력하는 기능
useon adecfcd
refactor: 로또티켓을 생성하는 메소드명을 수정하고 private 메소드로 수정한다
useon f8cc403
feat: 당첨 번호를 입력 받는다
useon 4c1ec60
feat: 잘못된 당첨 번호 입력시 throw예외발생, 에러메세지 출력, 재입력을 받는다
useon 1f37ecb
fix: 당첨 번호가 받아와지지 않는 문제를 해결한다
useon 018e536
refactor: 출력 형식에 알맞게 수정한다
useon 4799f01
refactor: 변수명과 메소드명을 수정한다
useon 7f0fef9
feat: 보너스 번호를 입력 받는다
useon 038aaa0
feat: 잘못된 보너스 번호 입력시 throw예외발생, 에러메세지 출력, 재입력을 받는다
useon 7c2219f
refactor: 에러 다루는 메소드를 만들어 게임 진행 메소드를 15라인 이내로 수정한다
useon 38a40c1
chore: prettier 설정을 수정한다
useon d37171d
feat: 발행된 로또와 당첨 번호, 보너스 번호를 비교하는 기능
useon d755706
refactor: 메소드명, 필드명을 수정한다
useon d20d5f9
refactor: 필드명, 메소드명을 수정한다
useon 0403fda
feat: 총 수익률을 구한다
useon 26e511b
refactor: 출력 형식에 알맞게 수정한다
useon 4d2c0c9
feat: 당첨 통계를 출력한다
useon fa90ea5
feat: 총 수익률을 출력한다
useon be13649
feat: 발행한 로또 번호는 오름차순으로 보여준다
useon 726fd6a
refactor: LottoTest를 통과할 수 있도록 코드를 수정한다
useon 63325bd
refactor: Lotto 클래스 수정됨에 따라 같은 로직으로 작동하도록 수정한다
useon de71fa9
feat: 당첨번호 콤마로 구분한 당첨번호 사이에 빈문자열 삭제
useon d6aeb7f
fix: 어플리케이션테스트가 통과되지 않는 문제를 해결한다
useon cbe205d
refactor: 불필요한 필드를 삭제하고 클래스명,필드명을 수정한다
useon 8e12d41
refactor: 중복코드를 수정한다
useon f6895a7
refactor: 불필요한 필드수를 줄인다
useon 9d11864
refactor: 클래스명을 수정한다
useon 210b069
refactor: 발행자와 구매자를 분리하여 컨트롤러에서 불필요한 필드수를 줄인다
useon 63db640
refactor: 당첨번호 입력값을 변환하는 코드를 분리한다
useon 26e5264
refactor: 게임의 단계를 구매, 추첨, 결과 세 단계로 나눠서 진행하도록 분리한다
useon 45b3e1d
feat: Lotto 클래스 테스트 코드를 구현한다
useon 14566b4
feat: Purchaser 클래스 테스트 코드를 구현한다
useon 389986d
refactor: 테스트를 하기 위해 코드를 수정한다
useon 43bcffc
feat: Bonus 클래스 테스트 코드를 구현한다
useon 53d4bf8
feat: Issuer 클래스 테스트 코드를 구현한다
useon d76bf1e
feat: Matcher 클래스 테스트 코드를 구현한다
useon 59c0161
feat: Calculator 클래스 테스트 코드를 구현한다
useon 9bfe70c
refactor: 테스트 코드 작성을 위해 수정한다
useon 5d3bda3
feat: Issuer 클래스 테스트 코드를 추가한다
useon 177accc
refactor: 상수화에 적절한 문자와 숫자를 상수화한다
useon a2d1eb2
docs: 리팩토링 기준을 추가한다
useon 6e2b176
refactor: node 환경에서 실행안되는 에러를 해결한다
useon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| module.exports = { | ||
| env: { | ||
| es2021: true, | ||
| node: true, | ||
| jest: true, | ||
| }, | ||
| extends: 'airbnb-base', | ||
| overrides: [ | ||
| { | ||
| env: { | ||
| node: true, | ||
| }, | ||
| files: ['.eslintrc.{js,cjs}'], | ||
| parserOptions: { | ||
| sourceType: 'script', | ||
| }, | ||
| }, | ||
| ], | ||
| parserOptions: { | ||
| ecmaVersion: 'latest', | ||
| sourceType: 'module', | ||
| }, | ||
| rules: { | ||
| 'import/extensions': 'off', | ||
| 'max-depth': ['error', 2], | ||
| 'max-lines-per-function': ['error', { max: 15 }], | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "singleQuote": true, | ||
| "semi": true, | ||
| "useTabs": false, | ||
| "tabWidth": 2, | ||
| "trailingComma": "all", | ||
| "printWidth": 100, | ||
| "bracketSpacing": true, | ||
| "arrowParens": "always", | ||
| "endOfLine": "auto" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import Bonus from '../src/Bonus.js'; | ||
|
|
||
| describe('보너스 클래스 테스트', () => { | ||
| const winningNumbers = [1, 2, 3, 4, 5, 6]; | ||
| test('보너스 번호가 숫자가 아니면 예외가 발생한다.', () => { | ||
| const inputBonusNumber = 'ㄱ'; | ||
| expect(() => { | ||
| new Bonus(winningNumbers, inputBonusNumber); | ||
| }).toThrow('[ERROR]'); | ||
| }); | ||
| test('보너스 번호가 1보다 작으면 예외가 발생한다.', () => { | ||
| const inputBonusNumber = -1; | ||
| expect(() => { | ||
| new Bonus(winningNumbers, inputBonusNumber); | ||
| }).toThrow('[ERROR]'); | ||
| }); | ||
| test('보너스 번호가 45보다 크면 예외가 발생한다.', () => { | ||
| const inputBonusNumber = 77; | ||
| expect(() => { | ||
| new Bonus(winningNumbers, inputBonusNumber); | ||
| }).toThrow('[ERROR]'); | ||
| }); | ||
| test('보너스 번호가 로또 번호와 중복되면 예외가 발생한다.', () => { | ||
| const inputBonusNumber = 1; | ||
| expect(() => { | ||
| new Bonus(winningNumbers, inputBonusNumber); | ||
| }).toThrow('[ERROR]'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import Calculator from '../src/Calculator.js'; | ||
|
|
||
| describe('Calculator 클래스 테스트', () => { | ||
| const purchaseAmount = 8000; | ||
| const matchStats = new Map([ | ||
| [5000, 1], | ||
| [50000, 0], | ||
| [1500000, 0], | ||
| [30000000, 0], | ||
| [2000000000, 0], | ||
| ]); | ||
| const { rateOfReturn } = new Calculator(purchaseAmount, matchStats); | ||
| test('수익률이 정확한지 확인한다.(소수점 둘째자리에서 반올림)', () => { | ||
| expect(rateOfReturn).toEqual(62.5); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import Issuer from '../src/Issuer'; | ||
|
|
||
| describe('Issuer 클래스 테스트', () => { | ||
| const { tickets } = new Issuer(3000); | ||
| test('구매한 로또 개수와 발행된 로또 개수가 같은지 확인한다.', () => { | ||
| expect(tickets).toHaveLength(3); | ||
| }); | ||
| test('발행된 각 티켓이 6개의 요소를 가지고 있는지 확인한다.', () => { | ||
| tickets.forEach((ticket) => { | ||
| expect(ticket).toHaveLength(6); | ||
| }); | ||
| }); | ||
| test('발행된 각 티켓의 요소가 전부 숫자인지 확인한다.', () => { | ||
| tickets.forEach((ticket) => { | ||
| ticket.forEach((value) => { | ||
| expect(typeof value).toEqual('number'); | ||
| }); | ||
| }); | ||
| }); | ||
| test('발행된 각 티켓의 요소가 전부 숫자 1 ~ 45 범위인지 확인한다.', () => { | ||
| tickets.forEach((ticket) => { | ||
| ticket.forEach((value) => { | ||
| expect(value).toBeGreaterThanOrEqual(1); | ||
| expect(value).toBeLessThanOrEqual(45); | ||
| }); | ||
| }); | ||
| }); | ||
| test('발행된 각 티켓이 오름차순으로 정렬되었는지 확인한다.', () => { | ||
| tickets.forEach((ticket) => { | ||
| const sortedTicket = [...ticket].sort((a, b) => a - b); | ||
| expect(ticket).toEqual(sortedTicket); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,29 @@ | ||
| import Lotto from "../src/Lotto.js"; | ||
| import Lotto from '../src/Lotto.js'; | ||
|
|
||
| describe("로또 클래스 테스트", () => { | ||
| test("로또 번호의 개수가 6개가 넘어가면 예외가 발생한다.", () => { | ||
| describe('로또 클래스 테스트', () => { | ||
| test('로또 번호의 개수가 6개가 넘어가면 예외가 발생한다.', () => { | ||
| expect(() => { | ||
| new Lotto([1, 2, 3, 4, 5, 6, 7]); | ||
| }).toThrow("[ERROR]"); | ||
| }).toThrow('[ERROR]'); | ||
| }); | ||
|
|
||
| // TODO: 이 테스트가 통과할 수 있게 구현 코드 작성 | ||
| test("로또 번호에 중복된 숫자가 있으면 예외가 발생한다.", () => { | ||
| test('로또 번호에 중복된 숫자가 있으면 예외가 발생한다.', () => { | ||
| expect(() => { | ||
| new Lotto([1, 2, 3, 4, 5, 5]); | ||
| }).toThrow("[ERROR]"); | ||
| }).toThrow('[ERROR]'); | ||
| }); | ||
|
|
||
| // 아래에 추가 테스트 작성 가능 | ||
| test('로또 번호에 1 미만인 숫자가 있으면 예외가 발생한다.', () => { | ||
| expect(() => { | ||
| new Lotto([0, 2, 3, 4, 5, 6]); | ||
| }).toThrow('[ERROR]'); | ||
| }); | ||
|
|
||
| test('로또 번호에 45 초과인 숫자가 있으면 예외가 발생한다.', () => { | ||
| expect(() => { | ||
| new Lotto([1, 2, 3, 4, 5, 77]); | ||
| }).toThrow('[ERROR]'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import Matcher from '../src/Matcher.js'; | ||
|
|
||
| describe('Matcher 클래스 테스트', () => { | ||
| const tickets = [ | ||
| [12, 13, 19, 33, 36, 37], | ||
| [1, 4, 7, 11, 32, 34], | ||
| [1, 2, 9, 11, 15, 38], | ||
| ]; | ||
| const bonusNumber = 38; | ||
| test('3개 일치 개수가 정확한지 확인한다.', () => { | ||
| const winningNumbers = [12, 13, 19, 20, 30, 40]; | ||
| const matcher = new Matcher(tickets, winningNumbers, bonusNumber); | ||
| const expectedMatchStatus = new Map([ | ||
| [5000, 1], | ||
| [50000, 0], | ||
| [1500000, 0], | ||
| [30000000, 0], | ||
| [2000000000, 0], | ||
| ]); | ||
| expect(matcher.matchStatus).toEqual(expectedMatchStatus); | ||
| }); | ||
| test('4개 일치 개수가 정확한지 확인한다.', () => { | ||
| const winningNumbers = [1, 4, 7, 11, 30, 45]; | ||
| const matcher = new Matcher(tickets, winningNumbers, bonusNumber); | ||
| const expectedMatchStatus = new Map([ | ||
| [5000, 0], | ||
| [50000, 1], | ||
| [1500000, 0], | ||
| [30000000, 0], | ||
| [2000000000, 0], | ||
| ]); | ||
| expect(matcher.matchStatus).toEqual(expectedMatchStatus); | ||
| }); | ||
| test('5개 일치 개수가 정확한지 확인한다.', () => { | ||
| const winningNumbers = [1, 4, 7, 11, 21, 32]; | ||
| const matcher = new Matcher(tickets, winningNumbers, bonusNumber); | ||
| const expectedMatchStatus = new Map([ | ||
| [5000, 0], | ||
| [50000, 0], | ||
| [1500000, 1], | ||
| [30000000, 0], | ||
| [2000000000, 0], | ||
| ]); | ||
| expect(matcher.matchStatus).toEqual(expectedMatchStatus); | ||
| }); | ||
| test('5개 일치 개수와 보너스 볼 일치 개수가 정확한지 확인한다.', () => { | ||
| const winningNumbers = [1, 2, 9, 11, 15, 21]; | ||
| const matcher = new Matcher(tickets, winningNumbers, bonusNumber); | ||
| const expectedMatchStatus = new Map([ | ||
| [5000, 0], | ||
| [50000, 0], | ||
| [1500000, 0], | ||
| [30000000, 1], | ||
| [2000000000, 0], | ||
| ]); | ||
| expect(matcher.matchStatus).toEqual(expectedMatchStatus); | ||
| }); | ||
| test('6개 일치 개수가 정확한지 확인한다.', () => { | ||
| const winningNumbers = [1, 4, 7, 11, 32, 34]; | ||
| const matcher = new Matcher(tickets, winningNumbers, bonusNumber); | ||
| const expectedMatchStatus = new Map([ | ||
| [5000, 0], | ||
| [50000, 0], | ||
| [1500000, 0], | ||
| [30000000, 0], | ||
| [2000000000, 1], | ||
| ]); | ||
| expect(matcher.matchStatus).toEqual(expectedMatchStatus); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import Purchaser from '../src/Purchaser.js'; | ||
|
|
||
| describe('구매자 클래스 테스트', () => { | ||
| test('구매 금액이 숫자가 아니면 예외가 발생한다.', () => { | ||
| expect(() => { | ||
| new Purchaser('안녕'); | ||
| }).toThrow('[ERROR]'); | ||
| }); | ||
| test('구매 금액이 1000원 보다 작으면 예외가 발생한다.', () => { | ||
| expect(() => { | ||
| new Purchaser('100'); | ||
| }).toThrow('[ERROR]'); | ||
| }); | ||
| test('구매 금액이 1000원 단위가 아니면 예외가 발생한다.', () => { | ||
| expect(() => { | ||
| new Purchaser('2400'); | ||
| }).toThrow('[ERROR]'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # 💫 javascript-lotto | ||
|
|
||
| ### 🎮 프로그램 동작 순서 | ||
|
|
||
| 1. 로또 구입금액을 입력받는다. | ||
| 2. 로또 구입개수를 출력한다. | ||
| 3. 로또를 구입개수만큼 발행한다. | ||
| 4. 발행된 로또 번호를 출력한다. | ||
| 5. 당첨 번호를 입력받는다. | ||
| 6. 보너스 번호를 입력받는다. | ||
| 7. 발행된 로또와 당첨 번호, 보너스 번호를 비교한다. | ||
| 8. 당첨 통계를 출력한다. | ||
| 9. 총 수익률을 구한다. | ||
| 10. 총 수익률을 출력한다. | ||
|
|
||
| ### ✨ 기능구현목록 | ||
|
|
||
| - [x] 로또 구입 금액을 입력받는 기능 | ||
| - [x] 사용자가 구입 금액을 잘 못 입력하는 경우 throw문을 사용해 예외를 발생시키고, '[ERROR]'로 시작하는 에러 메시지를 출력하고 해당 부분부터 입력을 다시 받는 기능 | ||
| - 숫자가 아닌 문자를 입력한 경우 | ||
| - 로또 구입 금액이 1000원 미만인 경우 | ||
| - 로또 구입 금액이 1000원 단위가 아닌 경우 | ||
| - [x] 로또 구입 개수를 구하고, 개수 만큼 로또를 발행하는 기능 | ||
| - [x] 로또 개수와, 로또 발행 번호를 출력하는 기능 | ||
| - [x] 당첨 번호를 입력 받는 기능 | ||
| - [x] 사용자가 당첨 번호를 잘 못 입력할 경우 throw문을 사용해 예외를 발생시키고, '[ERROR]'로 시작하는 에러 메시지를 출력하고 해당 부분부터 입력을 다시 받는 기능 | ||
| - ','로 구분하지 않은 경우 | ||
| - 숫자 6개를 입력하지 않은 경우 | ||
| - 1~45 범위에 해당 하는 숫자가 아닌 경우 | ||
| - 숫자가 중복되는 경우 | ||
| - [x] 보너스 번호를 입력 받는 기능 | ||
| - [x] 사용자가 보너스 번호를 잘 못 입력할 경우 throw문을 사용해 예외를 발생시키고, '[ERROR]'로 시작하는 에러 메시지를 출력하고 해당 부분부터 입력을 다시 받는 기능 | ||
| - 숫자가 아닌 문자를 입력한 경우 | ||
| - 당첨 번호에 포함된 번호를 입력한 경우 | ||
| - [x] 발행된 로또와 당첨 번호, 보너스 번호를 비교하여 당첨 동계를 구하는 기능 | ||
| - [x] 총 수익률을 구하는 기능 | ||
| - [x] 당첨 통계를 출력하는 기능 | ||
| - [x] 총 수익률을 출력하는 기능 | ||
|
|
||
| ### 🔨 리팩토링기준 | ||
|
|
||
| - 요구사항 및 피드백에 걸맞게 구현한다. | ||
| - MVC 패턴에 따라 코드를 분리한다. | ||
| - 메소드가 하나의 기능만 하도록 구현한다. | ||
| - 불필요한 의존성이 없는 코드를 지향한다. | ||
| - 상수화에 적절한 문자와 숫자를 판단하여 상수화를 진행한다. | ||
|
|
||
| ### 🧪 테스트구현목록 | ||
|
|
||
| - [x] Lotto 클래스 테스트 코드 구현 | ||
|
|
||
| - 로또 번호의 개수가 6개가 넘어가면 예외가 발생한다. | ||
| - 로또 번호에 중복된 숫자가 있으면 예외가 발생한다. | ||
| - 로또 번호에 1 미만인 숫자가 있으면 예외가 발생한다. | ||
| - 로또 번호에 45 초과인 숫자가 있으면 예외가 발생한다. | ||
|
|
||
| - [x] Purchaser 클래스 테스트 코드 구현 | ||
|
|
||
| - 구매 금액이 숫자가 아니면 예외가 발생한다. | ||
| - 구매 금액이 1000원 보다 작으면 예외가 발생한다. | ||
| - 구매 금액이 1000원 단위가 아니면 예외가 발생한다. | ||
|
|
||
| - [x] Bonus 클래스 테스트 코드 구현 | ||
|
|
||
| - 보너스 번호가 숫자가 아니면 예외가 발생한다. | ||
| - 보너스 번호가 1보다 작으면 예외가 발생한다. | ||
| - 보너스 번호가 45보다 크면 예외가 발생한다. | ||
| - 보너스 번호가 로또 번호와 중복되면 예외가 발생한다. | ||
|
|
||
| - [x] Issuer 클래스 테스트 코드 구현 | ||
|
|
||
| - 구매한 로또 개수와 발행된 로또 개수가 같은지 확인한다. | ||
| - 발행된 각 티켓이 6개의 요소를 가지고 있는지 확인한다. | ||
| - 발행된 각 티켓의 요소가 전부 숫자인지 확인한다. | ||
| - 발행된 각 티켓의 요소가 전부 숫자 1 ~ 45 범위인지 확인한다. | ||
| - 발행된 각 티켓이 오름차순으로 정렬되었는지 확인한다. | ||
|
|
||
| - [x] Matcher 클래스 테스트 코드 구현 | ||
|
|
||
| - 3개 일치 개수가 정확한지 확인한다. | ||
| - 4개 일치 개수가 정확한지 확인한다. | ||
| - 5개 일치 개수가 정확한지 확인한다. | ||
| - 5개 일치 개수와 보너스 볼 일치 개수가 정확한지 확인한다. | ||
| - 6개 일치 개수가 정확한지 확인한다. | ||
|
|
||
| - [x] Calculator 클래스 테스트 코드 구현 | ||
| - 수익률이 정확한지 확인한다.(소수점 둘째자리에서 반올림) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,13 @@ | ||
| import Controller from './Controller.js'; | ||
|
|
||
| class App { | ||
| async play() {} | ||
| constructor() { | ||
| this.controller = new Controller(); | ||
| } | ||
|
|
||
| async play() { | ||
| await this.controller.progress(); | ||
| } | ||
| } | ||
|
|
||
| export default App; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { BONUS_NUMBER } from './constants/Error.js'; | ||
| import { GAME } from './constants/Setting.js'; | ||
|
|
||
| class Bonus { | ||
| #number; | ||
|
|
||
| constructor(winningNumbers, inputBonusNumber) { | ||
| const bonusNumber = Number(inputBonusNumber); | ||
| this.#validate(winningNumbers, bonusNumber); | ||
| this.#number = bonusNumber; | ||
| } | ||
|
|
||
| #validate(winningNumbers, bonusNumber) { | ||
| if (Number.isNaN(bonusNumber)) { | ||
| throw new Error(BONUS_NUMBER.notNumber); | ||
| } | ||
| if (bonusNumber < GAME.minNumber || bonusNumber > GAME.maxNumber) { | ||
| throw new Error(BONUS_NUMBER.invalidRange); | ||
| } | ||
| if (winningNumbers.includes(bonusNumber)) { | ||
| throw new Error(BONUS_NUMBER.notWinningNumber); | ||
| } | ||
| } | ||
|
|
||
| get bonusNumber() { | ||
| return this.#number; | ||
| } | ||
| } | ||
|
|
||
| export default Bonus; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
정말 좋은 README네요,, 배우고 갑니다. 저도 마지막주차는 더 상세한 기능 목록 작성해봐야겠어요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
도움이 되었다니 저도 기분이 좋습니다 😊👍