-
Notifications
You must be signed in to change notification settings - Fork 168
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
[2단계 - 웹 기반 로또 게임] 윤생(이윤성) 미션 제출합니다. #207
Changes from 51 commits
7b152f5
269cb6c
0e3a3c6
3b584d7
2258db4
2a569d0
8bb63d6
d879324
2a36af9
5314e99
890c7ad
1160561
9f6784a
b033d49
93b2700
6b4f4cb
9edb2f8
7a34223
655c598
fc1749f
d68b2d4
5947151
0625dc1
976c8c6
8ed30f1
6e4bf93
4ab2c3f
7f43051
f64bcf4
ba5d8f7
eaf60aa
2b8c94a
37afdc1
0e8b8f0
509a79a
024d4b5
890e490
0cfb233
2a53008
d5eb3ac
04d83c1
d73d92a
d672ddd
f305047
d2f3db2
b139d5d
c1c9af1
eb6e0fa
f504837
b9d8bab
79cae3b
fcf6243
c8a2781
267686b
836f7a2
bf9ad43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import LottoMachine from '../src/domain/LottoMachine'; | ||
|
||
describe('LottoMachine 클래스입니다.', () => { | ||
const lottoMachine = new LottoMachine(1000); | ||
test.each([ | ||
[1000, 1], | ||
[2000, 2], | ||
[3000, 3], | ||
])('금액을 받으면 구매해야 할 올바른 수량 반환한다.', (money, expected) => { | ||
expect(lottoMachine.calcLottoAmount(money)).toEqual(expected); | ||
}); | ||
test.each([1001, 10015, 34678])('잘못된 금액을 받으면 에러를 반환한다.', (money) => { | ||
expect(() => lottoMachine.calcLottoAmount(money)).toThrow(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-disable max-params */ | ||
import LottoRank from '../src/domain/LottoRank'; | ||
|
||
describe('LottoRank 객체입니다.', () => { | ||
const winRankByMatchCount = (matchCount, hasBonus, expected) => { | ||
expect(LottoRank.getWinRank(matchCount, hasBonus)).toEqual(expected); | ||
}; | ||
|
||
test.each([ | ||
[0, true, LottoRank.PRIZE.MISS.RANK], | ||
[0, false, LottoRank.PRIZE.MISS.RANK], | ||
[1, true, LottoRank.PRIZE.MISS.RANK], | ||
[1, false, LottoRank.PRIZE.MISS.RANK], | ||
[2, true, LottoRank.PRIZE.MISS.RANK], | ||
[2, false, LottoRank.PRIZE.MISS.RANK], | ||
])('로또등수가 낙첨인지 판단', winRankByMatchCount); | ||
|
||
test.each([ | ||
[3, true, LottoRank.PRIZE.FIFTH.RANK], | ||
[3, false, LottoRank.PRIZE.FIFTH.RANK], | ||
])('로또 등수가 5등인지 판단(3개 일치)', winRankByMatchCount); | ||
|
||
test.each([ | ||
[4, true, LottoRank.PRIZE.FOURTH.RANK], | ||
[4, false, LottoRank.PRIZE.FOURTH.RANK], | ||
])('로또 등수가 4등인지 판단(4개 일치)', winRankByMatchCount); | ||
|
||
test.each([[5, false, LottoRank.PRIZE.THIRD.RANK]])( | ||
'로또 등수가 3등인지 판단(5개 일치)', | ||
winRankByMatchCount, | ||
); | ||
|
||
test.each([[5, true, LottoRank.PRIZE.SECOND.RANK]])( | ||
'로또 등수가 2등인지 판단(5개 일치 + 보너스볼 일치)', | ||
winRankByMatchCount, | ||
); | ||
|
||
test.each([[6, false, LottoRank.PRIZE.FIRST.RANK]])( | ||
'로또 등수가 1등인지 판단(6개 일치)', | ||
winRankByMatchCount, | ||
); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,42 @@ | ||
import { isPositiveInteger, isValidRestartCommand } from '../src/validation'; | ||
import { | ||
isPositiveInteger, | ||
isValidRestartCommand, | ||
isValidLottoNumber, | ||
isDuplicateNumbers, | ||
} from '../src/validation'; | ||
|
||
describe('유효성 검증 테스트입니다.', () => { | ||
test.each([1.11, null, undefined, 'string', {}])( | ||
'양의 정수가 아니면 false를 반환한다.', | ||
(value) => { | ||
expect(isPositiveInteger(Number(value))).toBeFalsy(); | ||
}, | ||
); | ||
test.each([1.11, -1, 2.3, 3.1])('양의 정수가 아니면 false를 반환한다.', (value) => { | ||
expect(isPositiveInteger(Number(value))).toBeFalsy(); | ||
}); | ||
|
||
test.each(['y', 'n'])('재시작 입력에서 y와 n를 받으면 true를 반환한다.', (input) => { | ||
expect(isValidRestartCommand(input)).toBeTruthy(); | ||
}); | ||
|
||
test.each([1, '1'])('재시작 입력에서 y와 n인 아닌 입력을 받으면 false를 반환한다.', (input) => { | ||
expect(isValidRestartCommand(input)).toBeFalsy(); | ||
test.each(['df', 's', 'w', 'a', 'gg'])( | ||
'재시작 입력에서 y와 n인 아닌 입력을 받으면 false를 반환한다.', | ||
(input) => { | ||
expect(isValidRestartCommand(input)).toBeFalsy(); | ||
}, | ||
); | ||
|
||
test.each([1, 2, 3, 4, 34, 44, 45])('유효한 로또 숫자이면 true를 반환한다.', (number) => { | ||
expect(isValidLottoNumber(number)).toBeTruthy(); | ||
}); | ||
|
||
test.each([-1, 0, 46, 47])('유효한 로또 숫자가 아니면 false를 반환한다.', (number) => { | ||
expect(isValidLottoNumber(number)).toBeFalsy(); | ||
}); | ||
|
||
test.each([ | ||
[[2, 1, 2, 3, 4, 5]], | ||
[[1, 1, 2, 3, 4, 5, 6]], | ||
[[5, 6, 7, 8, 44, 44]], | ||
[[1, 44, 45, 42, 43, 44]], | ||
[[1, 13, 8, 16, 4, 12, 15, 16]], | ||
[[10, 11, 12, 13, 14]], | ||
])('로또 번호가 중복되었는지와 길이(갯수)가 유효한지 검사한다.', (numbers) => { | ||
expect(isDuplicateNumbers(numbers)).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,89 @@ | ||
<!DOCTYPE html> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. html indent... 적용해보았습니다. vscode에서 전체 선택해서 command + K , command + F 하면 되었어요!! 감사합니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 좋습니다 |
||
<html lang="ko"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>🎱 행운의 로또</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
</head> | ||
|
||
<body> | ||
<div id="app"> | ||
<h1>🎱 행운의 로또</h1> | ||
<div class="modal"> | ||
<article class="win-result-container"> | ||
<button class="modal-close-btn">X</button> | ||
<section class="modal-body"> | ||
<h3 class="lotto-subtitle">🏆 당첨 통계 🏆</h3> | ||
<table class="result-table"> | ||
<thead> | ||
<tr> | ||
<th>일치 갯수</th> | ||
<th>당첨금</th> | ||
<th>당첨 갯수</th> | ||
</tr> | ||
</thead> | ||
<tbody class="result-table-body"> | ||
<tr> | ||
<td>3개</td> | ||
<td>5,000</td> | ||
</tr> | ||
<tr> | ||
<td>4개</td> | ||
<td>50,000</td> | ||
</tr> | ||
<tr> | ||
<td>5개</td> | ||
<td>1,500,000</td> | ||
</tr> | ||
<tr> | ||
<td>5개 + 보너스 볼</td> | ||
<td>30,000,000</td> | ||
</tr> | ||
<tr> | ||
<td>6개</td> | ||
<td>2,000,000,000</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<button class="modal-restart-btn">다시 시작하기</button> | ||
</section> | ||
</article> | ||
</div> | ||
<script type="module" src="./src/js/index.js"></script> | ||
<header>🎱 행운의 로또</header> | ||
<main> | ||
<article id="app"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 시맨틱 태그도 사용해보았습니다! |
||
<h3 class="lotto-subtitle">🎱 내 번호 당첨 확인 🎱</h3> | ||
<form class="payments-container"> | ||
<p class="payments-notice">구입할 금액을 입력해주세요.</p> | ||
<input class="payments-input" type="number" placeholder="금액" step="1000" min="0"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 다양한 input 속성을 사용해보았습니다. 로또 금액에 맞게 step도 1000원으로 적용시켰고, 최소 금액은 마이너스가 되지 않도록 min = 0을 적용시켰습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 굿굿 좋습니다! |
||
<button class="payments-btn" type="submit">구입</button> | ||
</form> | ||
<form class="winning-lotto-container"> | ||
<p class="winning-lotto-notice">지난 주 당첨번호 6개와 보너스 번호 1개를 입력해주세요.</p> | ||
<div class="winning-lotto-title-container"> | ||
<span>당첨번호</span> | ||
<span>보너스 번호</span> | ||
</div> | ||
<section class="winning-numbers-input-container"> | ||
<div class="winning-numbers"> | ||
<input class="winning-number-input" type="number" min="1" max="45"> | ||
<input class="winning-number-input" type="number" min="1" max="45"> | ||
<input class="winning-number-input" type="number" min="1" max="45"> | ||
<input class="winning-number-input" type="number" min="1" max="45"> | ||
<input class="winning-number-input" type="number" min="1" max="45"> | ||
<input class="winning-number-input" type="number" min="1" max="45"> | ||
</div> | ||
<div class="bonus-number"> | ||
<input class="bonus-number-input" type="number" min="1" max="45"> | ||
</div> | ||
</section> | ||
<button class="result-btn" type="submit" disabled>결과 확인하기</button> | ||
</form> | ||
</article> | ||
</main> | ||
<footer> | ||
Copyright 2023. woowacourse | ||
</footer> | ||
</body> | ||
</html> | ||
<script type="module" src="./src/js/index.js"></script> | ||
|
||
</html> |
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.
이부분을 등수별로 분리해보았습니다!
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.
넵넵 좋아요~~~!