-
Notifications
You must be signed in to change notification settings - Fork 6
[정찬욱] 로또 미션 Step1 #2
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
seeyoujeong
wants to merge
88
commits into
fe-clean-code-study:seeyoujeong
Choose a base branch
from
seeyoujeong:main
base: seeyoujeong
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 55 commits
Commits
Show all changes
88 commits
Select commit
Hold shift + click to select a range
ef743b3
chore: 스크립트 설정 및 리드미 수정
seeyoujeong 9f95561
feat: 폴더구조 설정
seeyoujeong de30d4e
test: 불필요한 테스트 삭제 및 tdd 방식으로 테스트 작성
seeyoujeong d579f9b
test: 로또 구입 관련 테스트 추가 및 Lotto 클래스에 구입 관련 로직 구현
seeyoujeong e855bbf
refactor: 테스트 파일에서 구현한 Lotto 클래스 분리
seeyoujeong e3e8ecc
feat: 이전 코드 삭제 후 Lotto 클래스 새로 구현
seeyoujeong f33d640
test: Lotto 클래스 테스트 코드 수정
seeyoujeong aced74a
refactor: isDuplicated 함수 추가 및 적용
seeyoujeong 5a7c226
feat: 로또 번호 유효성 검사 추가
seeyoujeong 56d244f
test: 로또 번호 유효성 검사 테스트 추가
seeyoujeong 4afa7f0
feat: 로또 번호 유효성 검사 추가
seeyoujeong fd17d31
test: 로또 번호 유효성 검사 테스트 추가
seeyoujeong 86dd7f4
feat: LottoMachine 클래스 추가
seeyoujeong e776555
test: LottoMachine 클래스 관련 테스트 추가
seeyoujeong cda3a77
refactor: getRandomNumber 함수 추가 및 적용
seeyoujeong 6f8ddc9
refactor: 로또 관련 숫자 상수화
seeyoujeong eca3349
refactor: 불변성 유지를 위해 deepCopy 함수 추가 및 적용
seeyoujeong 5f550f1
test: LottoMachine 클래스 수정사항 반영
seeyoujeong 10e8c4d
refactor: 보너스 번호 유효성 검사에 사용할 로직 분리
seeyoujeong 40f1f10
feat: WinningLotto 클래스 추가
seeyoujeong ce82980
test: WinningLotto 클래스 테스트 추가
seeyoujeong c4d6d2b
refactor: 상수값을 Lotto 클래스로 이동하고 적용
seeyoujeong eb7368d
refactor: lottos배열의 원소를 Lotto 인스턴스값으로 수정
seeyoujeong bc07e24
fix: WinningLotto 클래스 export 추가
seeyoujeong 82d0a01
feat: LottoCalculator 클래스 추가
seeyoujeong a85d026
test: LottoCalculator 클래스 테스트 추가
seeyoujeong d66eca8
feat: 금액 관련 프로퍼티 및 매개변수 추가
seeyoujeong d4e99f2
test: 금액 관련 부분 및 중복 코드 수정
seeyoujeong 89b8eaf
feat: 수익률 로직 추가
seeyoujeong e9f317e
test: 수익률 관련 테스트 추가
seeyoujeong fbf2d4f
refactor: 순수 함수로 수정
seeyoujeong a9471c4
feat: readLineAsynce 함수 추가
seeyoujeong 7ebaa96
feat: InputManager 클래스 추가
seeyoujeong 56a4598
feat: OutputManager 클래스 추가
seeyoujeong c41a1fc
fix: 정수인지 검사하는 유효성 검사로 수정
seeyoujeong 4f78672
feat: 구입 금액 입력 구현
seeyoujeong df5b826
feat: 당첨 번호, 보너스 번호 입력 및 당첨 통계 출력 구현
seeyoujeong a5c07c1
refactor: main 정리
seeyoujeong 0bc5f15
refactor: #count 프로퍼티 삭제
seeyoujeong 3ccfbbc
refactor: 정수 검사 조건 수정
seeyoujeong 88004ac
feat: 유효성 감사 유틸 추가
seeyoujeong 502416e
refactor: 유효성 검사 유틸을 활용해 수정
seeyoujeong 783e136
feat: 입출력 매니저에 유효성 검사 추가
seeyoujeong 2ec79a3
refactor: 화살표 함수로 수정
seeyoujeong b7c3d93
refactor: 불필요한 파일 삭제
seeyoujeong 0e4cade
feat: #createLotto에서 로또 번호 정렬되게 수정
seeyoujeong 48d0c42
refactor: domain 폴더명을 model로 수정
seeyoujeong 4bd886c
fix: 누락된 정수 유효성 검사 추가 및 createWithBonusNumberLater 메서드 추가
seeyoujeong 9b86217
test: 정수 유효성 검사 테스트 추가
seeyoujeong b0a1390
feat: 보너스 번호를 나중에 받을 수 있게 수정
seeyoujeong e4e4f4f
feat: 컨트롤러 레이어 추가
seeyoujeong ee9f635
feat: 뷰 레이어 추가
seeyoujeong 43c8791
feat: MVC 패턴으로 구현
seeyoujeong ddaf645
fix: 동일한 변수명이 있어서 attachBonusNumber로 수정
seeyoujeong 2b4897a
fix: ci 테스트 실패 오류 해결
seeyoujeong 046974b
feat: LottoNumber 클래스 추가
seeyoujeong 49641e8
test: LottoNumber 클래스 테스트 추가
seeyoujeong af050c1
refactor: LottoNumber 클래스 적용
seeyoujeong 85b4a72
test: 불필요한 테스트 삭제
seeyoujeong 6e5ac02
feat: retryOnFailureAsync 함수 추가
seeyoujeong bc8c1a7
refactor: 입력에서 예외처리 분리
seeyoujeong 60d2154
refactor: 로또에 관한 정보 수정 및 내부 로직 수정
seeyoujeong 6dcaa4f
refactor: constants 폴더 생성하고 로또 순위 정보 이동
seeyoujeong 26037c2
feat: formatKoreanCurrency 함수 추가
seeyoujeong 8fb164f
refactor: 로또 순위 정보를 바탕으로 결과를 보여주게 수정
seeyoujeong 0fd967b
refactor: 가격 관련 부분 수정
seeyoujeong f787d18
test: 상금 테스트 오류 수정
seeyoujeong 92a4f4f
refactor: 당첨 번호 입력에 대한 예외처리 로직 수정
seeyoujeong 58fd431
feat: 배열관련 유틸 함수 추가
seeyoujeong 074b130
refactor: 로또 번호 생성하는 로직 수정
seeyoujeong d5721d7
refactor: 로또 관련 상수 분리
seeyoujeong 258249e
refactor: 불필요한 파일 삭제
seeyoujeong f3c451b
refactor: LottoCalculator 클래스 분리하고 적용
seeyoujeong b41cc97
test: LottoCalculator 클래스 삭제하고 LottoMatcher, LottoResult 클래스 테스트 추가
seeyoujeong 15933cb
fix: 잘못된 import 수정
seeyoujeong daf3e24
refactor: 클래스명 수정
seeyoujeong bbf6649
feat: 재시작 기능 추가
seeyoujeong 59db060
style: 코드 배치 수정
seeyoujeong ff3fb40
feat: 에러 메세지 관련 상수 추가
seeyoujeong 42f46b7
refactor: 파일명 수정
seeyoujeong 7006658
feat: 에러 메세지 관련 유틸 추가
seeyoujeong e0cd64f
feat: 에러 메세지 관련 출력 함수 추가
seeyoujeong de23f68
refactor: 에러 메세지 수정
seeyoujeong 4477059
test: 에러 메시지 수정으로 인한 테스트 수정
seeyoujeong d38145f
refactor: 에러 메세지 관련 코드 수정
seeyoujeong 1956965
feat: 수익률이 정수인지 아닌지에 따른 반환값 수정
seeyoujeong 19ab847
feat: 다시 시작 취소할때 아무키 입력으로 수정
seeyoujeong b3646fd
Merge pull request #1 from seeyoujeong/step2
seeyoujeong 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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # 자동차 경주 미션 | ||
| # 로또 미션 | ||
|
|
||
| ## 참고링크 및 저장소 | ||
|
|
||
|
|
||
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
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,62 @@ | ||
| import { describe, test, expect } from "vitest"; | ||
| import { Lotto } from "../model/index.js"; | ||
|
|
||
| describe("Lotto 클래스 테스트.", () => { | ||
| test.each([ | ||
| { value: 1 }, | ||
| { value: "1" }, | ||
| { value: true }, | ||
| { value: null }, | ||
| { value: undefined }, | ||
| { value: {} }, | ||
| ])( | ||
| "로또 번호로 적합하지 않은 값($value)을 받으면 오류가 발생한다.", | ||
| ({ value }) => { | ||
| expect(() => new Lotto(value)).toThrowError( | ||
| "로또 번호로 적합하지 않은 값입니다." | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| test("로또 번호가 6개 초과이면 오류가 발생한다.", () => { | ||
| expect(() => new Lotto([1, 2, 3, 4, 5, 6, 7])).toThrowError( | ||
| "로또 번호는 6개여야 합니다." | ||
| ); | ||
| }); | ||
|
|
||
| test("로또 번호가 6개 미만이면 오류가 발생한다.", () => { | ||
| expect(() => new Lotto([1, 2, 3, 4, 5])).toThrowError( | ||
| "로또 번호는 6개여야 합니다." | ||
| ); | ||
| }); | ||
|
|
||
| test("로또 번호 중에 숫자가 아닌 값이 있으면 오류가 발생한다.", () => { | ||
| expect(() => new Lotto(["a", 1, 2, 3, 4, 5])).toThrowError( | ||
| "로또 번호 중에 적합하지 않은 값이 있습니다." | ||
| ); | ||
| }); | ||
|
|
||
| test("로또 번호 중에 1보다 작은 번호가 있으면 오류가 발생한다.", () => { | ||
| expect(() => new Lotto([0, 2, 3, 4, 5, 45])).toThrowError( | ||
| "로또 번호 중에 1보다 작은 번호가 있습니다." | ||
| ); | ||
| }); | ||
|
|
||
| test("로또 번호 중에 45보다 큰 번호가 있으면 오류가 발생한다.", () => { | ||
| expect(() => new Lotto([1, 2, 3, 4, 5, 46])).toThrowError( | ||
| "로또 번호 중에 45보다 큰 번호가 있습니다." | ||
| ); | ||
| }); | ||
|
|
||
| test("로또 번호 중에 중복되는 번호가 있으면 오류가 발생한다.", () => { | ||
| expect(() => new Lotto([1, 2, 3, 4, 5, 5])).toThrowError( | ||
| "중복되는 로또 번호가 있습니다." | ||
| ); | ||
| }); | ||
|
|
||
| test("로또 번호를 가져옵니다.", () => { | ||
| const lotto = new Lotto([1, 2, 3, 4, 5, 6]); | ||
|
|
||
| expect(lotto.numbers).toEqual([1, 2, 3, 4, 5, 6]); | ||
| }); | ||
| }); |
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,121 @@ | ||
| import { describe, expect, test, vi } from "vitest"; | ||
| import { | ||
| LottoMachine, | ||
| WinningLotto, | ||
| LottoCalculator, | ||
| Lotto, | ||
| } from "../model/index.js"; | ||
|
|
||
| describe("LottoCalculator 클래스 테스트", () => { | ||
| test("1등부터 5등까지 당첨된 수를 가져온다.", () => { | ||
| const { price, lottos } = new LottoMachine(6000); | ||
| const winningLotto = new WinningLotto([1, 2, 3, 4, 5, 6], 7); | ||
|
|
||
| const { winningCounts } = new LottoCalculator({ | ||
| price, | ||
| lottos, | ||
| winningLotto, | ||
| }); | ||
|
|
||
| expect(winningCounts).toHaveProperty("1"); | ||
| expect(winningCounts).toHaveProperty("2"); | ||
| expect(winningCounts).toHaveProperty("3"); | ||
| expect(winningCounts).toHaveProperty("4"); | ||
| expect(winningCounts).toHaveProperty("5"); | ||
|
|
||
| expect(typeof winningCounts[1]).toBe("number"); | ||
| expect(typeof winningCounts[2]).toBe("number"); | ||
| expect(typeof winningCounts[3]).toBe("number"); | ||
| expect(typeof winningCounts[4]).toBe("number"); | ||
| expect(typeof winningCounts[5]).toBe("number"); | ||
| }); | ||
|
|
||
| test("로또 번호 중에 1등 당첨이 하나있다.", () => { | ||
| const { price, lottos } = createLottoMachineMock([1, 2, 3, 4, 5, 6]); | ||
| const winningLotto = new WinningLotto([1, 2, 3, 4, 5, 6], 7); | ||
|
|
||
| const { winningCounts } = new LottoCalculator({ | ||
| price, | ||
| lottos, | ||
| winningLotto, | ||
| }); | ||
|
|
||
| expect(winningCounts).toHaveProperty("1", 1); | ||
| }); | ||
|
|
||
| test("로또 번호 중에 2등 당첨이 하나있다.", () => { | ||
| const { price, lottos } = createLottoMachineMock([1, 2, 3, 4, 5, 7]); | ||
| const winningLotto = new WinningLotto([1, 2, 3, 4, 5, 6], 7); | ||
|
|
||
| const { winningCounts } = new LottoCalculator({ | ||
| price, | ||
| lottos, | ||
| winningLotto, | ||
| }); | ||
|
|
||
| expect(winningCounts).toHaveProperty("2", 1); | ||
| }); | ||
|
|
||
| test("로또 번호 중에 3등 당첨이 하나있다.", () => { | ||
| const { price, lottos } = createLottoMachineMock([1, 2, 3, 4, 5, 8]); | ||
| const winningLotto = new WinningLotto([1, 2, 3, 4, 5, 6], 7); | ||
|
|
||
| const { winningCounts } = new LottoCalculator({ | ||
| price, | ||
| lottos, | ||
| winningLotto, | ||
| }); | ||
|
|
||
| expect(winningCounts).toHaveProperty("3", 1); | ||
| }); | ||
|
|
||
| test("로또 번호 중에 4등 당첨이 하나있다.", () => { | ||
| const { price, lottos } = createLottoMachineMock([1, 2, 3, 4, 8, 9]); | ||
| const winningLotto = new WinningLotto([1, 2, 3, 4, 5, 6], 7); | ||
|
|
||
| const { winningCounts } = new LottoCalculator({ | ||
| price, | ||
| lottos, | ||
| winningLotto, | ||
| }); | ||
|
|
||
| expect(winningCounts).toHaveProperty("4", 1); | ||
| }); | ||
|
|
||
| test("로또 번호 중에 5등 당첨이 하나있다.", () => { | ||
| const { price, lottos } = createLottoMachineMock([1, 2, 3, 8, 9, 10]); | ||
| const winningLotto = new WinningLotto([1, 2, 3, 4, 5, 6], 7); | ||
|
|
||
| const { winningCounts } = new LottoCalculator({ | ||
| price, | ||
| lottos, | ||
| winningLotto, | ||
| }); | ||
|
|
||
| expect(winningCounts).toHaveProperty("5", 1); | ||
| }); | ||
|
|
||
| test("수익률을 가져온다.", () => { | ||
| const { price, lottos } = createLottoMachineMock( | ||
| [1, 2, 3, 8, 9, 10], | ||
| 10000 | ||
| ); | ||
| const winningLotto = new WinningLotto([1, 2, 3, 4, 5, 6], 7); | ||
|
|
||
| const { rateOfReturn } = new LottoCalculator({ | ||
| price, | ||
| lottos, | ||
| winningLotto, | ||
| }); | ||
|
|
||
| expect(rateOfReturn).toBe(50); | ||
| }); | ||
| }); | ||
|
|
||
| function createLottoMachineMock(lottoNumbers, price = 1000) { | ||
| const lotto = new Lotto(lottoNumbers); | ||
| const lottoMachineMock = vi.fn(); | ||
| lottoMachineMock.mockReturnValueOnce({ price, lottos: [lotto] }); | ||
|
|
||
| return lottoMachineMock(); | ||
| } |
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,38 @@ | ||
| import { describe, test, expect } from "vitest"; | ||
| import { LottoMachine } from "../model/index.js"; | ||
|
|
||
| describe("LottoMachine 클래스 테스트", () => { | ||
| test("로또를 구입할 때 정수가 아닌 값을 받으면 오류가 발생한다.", () => { | ||
| expect(() => new LottoMachine("1")).toThrowError( | ||
| "로또 구입 금액으로 정수를 입력해야 합니다." | ||
| ); | ||
| }); | ||
|
|
||
| test("로또를 구입할 때 1000원미만의 값을 받으면 오류가 발생한다.", () => { | ||
| expect(() => new LottoMachine(999)).toThrowError( | ||
| "로또 구입 금액은 1000원이상이어야 합니다." | ||
| ); | ||
| }); | ||
|
|
||
| test.each([ | ||
| { price: 1001, count: 1 }, | ||
| { price: 2500, count: 2 }, | ||
| { price: 3999, count: 3 }, | ||
| { price: 10999, count: 10 }, | ||
| ])( | ||
| "로또를 $price원만큼 구매하면 $count장을 발행한다.", | ||
| ({ price, count }) => { | ||
| const lottoMachine = new LottoMachine(price); | ||
|
|
||
| expect(lottoMachine.count).toBe(count); | ||
| } | ||
| ); | ||
|
|
||
| test("무작위 번호 6개가 적힌 로또를 받는다.", () => { | ||
| const lottoMachine = new LottoMachine(1000); | ||
|
|
||
| const lotto = lottoMachine.lottos[0]; | ||
|
|
||
| expect(lotto.numbers).toHaveLength(6); | ||
| }); | ||
| }); |
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,49 @@ | ||
| import { describe, expect, test } from "vitest"; | ||
| import { WinningLotto } from "../model/index.js"; | ||
|
|
||
| describe("WinningLotto 클래스 테스트", () => { | ||
| test("보너스 번호가 정수가 아니면 오류가 발생한다.", () => { | ||
| const lottoNumbers = [1, 2, 3, 4, 5, 6]; | ||
| const bonusNumber = "a"; | ||
|
|
||
| expect(() => new WinningLotto(lottoNumbers, bonusNumber)).toThrowError( | ||
| "보너스 번호는 정수여야 합니다." | ||
| ); | ||
| }); | ||
|
|
||
| test("보너스 번호가 1보다 작으면 오류가 발생한다.", () => { | ||
| const lottoNumbers = [1, 2, 3, 4, 5, 6]; | ||
| const bonusNumber = 0; | ||
|
|
||
| expect(() => new WinningLotto(lottoNumbers, bonusNumber)).toThrowError( | ||
| "보너스 번호는 1이상이어야 합니다." | ||
| ); | ||
| }); | ||
|
|
||
| test("보너스 번호가 45보다 크면 오류가 발생한다.", () => { | ||
| const lottoNumbers = [1, 2, 3, 4, 5, 6]; | ||
| const bonusNumber = 46; | ||
|
|
||
| expect(() => new WinningLotto(lottoNumbers, bonusNumber)).toThrowError( | ||
| "보너스 번호는 45이하여야 합니다." | ||
| ); | ||
| }); | ||
|
|
||
| test("당첨 번호 중에 보너스 번호와 중복되는 번호가 있으면 오류가 발생한다.", () => { | ||
| const lottoNumbers = [1, 2, 3, 4, 5, 6]; | ||
| const bonusNumber = 6; | ||
|
|
||
| expect(() => new WinningLotto(lottoNumbers, bonusNumber)).toThrowError( | ||
| "당첨 번호 중에 보너스 번호와 중복되는 번호가 있습니다." | ||
| ); | ||
| }); | ||
|
|
||
| test("보너스 번호를 가져온다.", () => { | ||
| const lottoNumbers = [1, 2, 3, 4, 5, 6]; | ||
| const bonusNumber = 45; | ||
|
|
||
| const winningLotto = new WinningLotto(lottoNumbers, bonusNumber); | ||
|
|
||
| expect(winningLotto.bonusNumber).toBe(45); | ||
| }); | ||
| }); |
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
| import { LottoCalculator } from "../model/index.js"; | ||
|
|
||
| const calculateWinningResults = ({ price, lottos, winningLotto }) => { | ||
| const { winningCounts, rateOfReturn } = new LottoCalculator({ | ||
| price, | ||
| lottos, | ||
| winningLotto, | ||
| }); | ||
|
|
||
| return { winningCounts, rateOfReturn }; | ||
| }; | ||
|
|
||
| export default calculateWinningResults; |
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 @@ | ||
| import { inputManager } from "../service/index.js"; | ||
| import { WinningLotto } from "../model/index.js"; | ||
|
|
||
| const createWinningLotto = async () => { | ||
| const attachBonusNumber = await inputManager.retryScan( | ||
| "> 당첨 번호를 입력해 주세요. ", | ||
| (inputValue) => { | ||
| const numbers = inputValue | ||
| .split(",") | ||
| .map((value) => Number(value.trim())); | ||
|
|
||
| return new WinningLotto(numbers); | ||
| } | ||
| ); | ||
|
|
||
| const winningLotto = await inputManager.retryScan( | ||
| "> 보너스 번호를 입력해 주세요. ", | ||
| (inputValue) => { | ||
| const bonusNumber = Number(inputValue); | ||
|
|
||
| return attachBonusNumber(bonusNumber); | ||
| } | ||
| ); | ||
|
|
||
| return winningLotto; | ||
| }; | ||
|
|
||
| export default createWinningLotto; | ||
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,3 @@ | ||
| export { default as purchaseLottos } from "./purchaseLottos.js"; | ||
| export { default as createWinningLotto } from "./createWinningLotto.js"; | ||
| export { default as calculateWinningResults } from "./calculateWinningResults.js"; |
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,17 @@ | ||
| import { LottoMachine } from "../model/index.js"; | ||
| import { inputManager } from "../service/index.js"; | ||
|
|
||
| const purchaseLottos = async () => { | ||
| const { price, count, lottos } = await inputManager.retryScan( | ||
| "> 구입 금액을 입력해 주세요. ", | ||
| (inputValue) => { | ||
| const numValue = Number(inputValue); | ||
|
|
||
| return new LottoMachine(numValue); | ||
| } | ||
| ); | ||
|
|
||
| return { price, count, lottos }; | ||
| }; | ||
|
|
||
| export default purchaseLottos; |
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,23 @@ | ||
| function main() { | ||
| console.log('main의 내용을 채워주세요'); | ||
| } | ||
| import { | ||
| purchaseLottos, | ||
| createWinningLotto, | ||
| calculateWinningResults, | ||
| } from "./controller/index.js"; | ||
| import { showPurchasedLottos, showWinningResults } from "./view/index.js"; | ||
|
|
||
| const main = async () => { | ||
| const { price, count, lottos } = await purchaseLottos(); | ||
|
|
||
| showPurchasedLottos(count, lottos); | ||
|
|
||
| const winningLotto = await createWinningLotto(); | ||
| const { winningCounts, rateOfReturn } = calculateWinningResults({ | ||
| price, | ||
| lottos, | ||
| winningLotto, | ||
| }); | ||
|
|
||
| showWinningResults(winningCounts, rateOfReturn); | ||
| }; | ||
|
|
||
| main(); |
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.
오오.. 이렇게 구현하셨군요..! 🧐