Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true,
jest: true,
},
parserOptions: {
ecmaVersion: 2022,
},
extends: ['airbnb-base', 'plugin:prettier/recommended', 'prettier'],
rules: {
'max-depth': ['error', 2],
'max-lines-per-function': ['error', 16],
'operator-linebreak': ['error', 'before'],
'no-unused-expressions': ['error', { allowTernary: true }],
},
};
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always",
"proseWrap": "never",
"endOfLine": "auto"
}
12 changes: 6 additions & 6 deletions __tests__/LottoTest.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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]');
});

// 아래에 추가 테스트 작성 가능
Expand Down
65 changes: 65 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# 🎲 로또 게임
> 우아한테크코스 프리코스 3주차

- 사용자는 구입 금액에 따라 로또를 구입할 수 있습니다.
- 로또 발행 시, 랜덤으로 숫자가 지정됩니다.
- 사용자는 자신이 구매한 로또의 결과와 총 수익률을 확인할 수 있습니다.

## ✨ 목차
- [기능 명세](#✨-기능-명세)
- [테스트 명세](#✨-테스트-명세)
- [결과](#✨-결과)
- [로또 게임](#로또-게임-플레이)
- [테스트](#테스트)
- [느낀 점](#✨-느낀-점)

## ✨ 기능 명세
### 게임 플로우
- [ ] 구입 금액 입력
- 1,000 원 단위 입력
- [ ] 구입 금액에 따른 로또 발행
- 1,000원 당 1장 발행
- 1장 당 랜덤 중복 없는 6개 번호 생성
- [ ] 당첨 번호 입력 안내 메시지 출력
- [ ] 당첨 번호 6개 입력
- 쉼표로 구분
- [ ] 보너스 번호 1개 입력
- [ ] 당첨 통계 출력
- [ ] 각 로또마다 일치 개수 계산
- [ ] 총 수익률 출력
- [ ] 수익률 계산
- [ ] 소수점 둘째 자리 반올림


### 에러 처리
- [ ] 로또 구입 금액 입력 관련
- [ ] 1,000원 단위 입력이 아닐 때
- [ ] 당첨 번호 입력 관련
- [ ] 번호의 개수가 6개가 넘어갔을 때
- [ ] 로또 번호에 중복된 숫자가 있을 때
- [ ] 각 번호의 범위가 1 ~ 45가 아닐 때
- [ ] 보너스 번호 입력 관련
- [ ] 번호의 범위가 1 ~ 45가 아닐 때
- [ ] 당첨 번호에 중복된 숫자가 있을 때

### 기타
- [ ] 코드 컨벤션 체크
- [ ] indent depth 2까지
- [ ] 1함수 1기능
- [ ] 함수의 길이 <= 15
- [ ] 테스트 코드 작성
- [ ] 도메인 로직 단위 테스트 구현
- [ ] else 지양


## ✨ 테스트 명세
- [ ] 로또 클래스 테스트
- [ ] 번호의 개수가 6개가 넘어갔을 때 예외 처리
- [ ] 로또 번호에 중복된 숫자가 있을 때 예외 처리

## ✨ 결과
### 로또 게임 플레이

### 테스트

## ✨ 느낀 점
Loading