Skip to content
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

bowling1 #1008

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
147 changes: 138 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,138 @@
# 볼링 게임 점수판
## 진행 방법
* 볼링 게임 점수판 요구사항을 파악한다.
* 요구사항에 대한 구현을 완료한 후 자신의 github 아이디에 해당하는 브랜치에 Pull Request(이하 PR)를 통해 코드 리뷰 요청을 한다.
* 코드 리뷰 피드백에 대한 개선 작업을 하고 다시 PUSH한다.
* 모든 피드백을 완료하면 다음 단계를 도전하고 앞의 과정을 반복한다.

## 온라인 코드 리뷰 과정
* [텍스트와 이미지로 살펴보는 온라인 코드 리뷰 과정](https://github.com/next-step/nextstep-docs/tree/master/codereview)
```
플레이어 이름은 (3 english letters)?: aaa
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | | | | | | | | | | |
1프레임 투구: 1
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1 | | | | | | | | | |
1프레임 투구: 2
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | | | | | | | | | |
2프레임 투구: 2
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | 2 | | | | | | | | |
2프레임 투구: 8
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | 2|/ | | | | | | | | |
3프레임 투구: 2
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | 2|/ | 2 | | | | | | | |
3프레임 투구: 3
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | 2|/ | 2|3 | | | | | | | |
4프레임 투구: 10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | 2|/ | 2|3 | X | | | | | | |
5프레임 투구: 10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | 2|/ | 2|3 | X | X | | | | | |
6프레임 투구: 10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | 2|/ | 2|3 | X | X | X | | | | |
7프레임 투구: 10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | 2|/ | 2|3 | X | X | X | X | | | |
8프레임 투구: 10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | 2|/ | 2|3 | X | X | X | X | X | | |
9프레임 투구: 10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | 2|/ | 2|3 | X | X | X | X | X | X | |
10프레임 투구: 10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | 2|/ | 2|3 | X | X | X | X | X | X | X |
10프레임 투구: 10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | 2|/ | 2|3 | X | X | X | X | X | X | X|X |
10프레임 투구: 10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|2 | 2|/ | 2|3 | X | X | X | X | X | X | X|X|X|
```

----
```
플레이어 이름은(3 english letters)?:aaa
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | | | | | | | | | | |
| | | | | | | | | | | |

1프레임 투구 :1
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1 | | | | | | | | | |
| | | | | | | | | | | |

1프레임 투구 :9
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | | | | | | | | | |
| | | | | | | | | | | |

2프레임 투구 :10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | | | | | | | | |
| | 20 | | | | | | | | | |

3프레임 투구 :10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | x | | | | | | | |
| | 20 | | | | | | | | | |

4프레임 투구 :10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | x | x | | | | | | |
| | 20 | 50 | | | | | | | | |

5프레임 투구 :2
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | x | x | 2 | | | | | |
| | 20 | 50 | 72 | | | | | | | |

5프레임 투구 :8
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | x | x | 2|/ | | | | | |
| | 20 | 50 | 72 | 92 | | | | | | |

6프레임 투구 :10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | x | x | 2|/ | x | | | | |
| | 20 | 50 | 72 | 92 | 112 | | | | | |

7프레임 투구 :10
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | x | x | 2|/ | x | x | | | |
| | 20 | 50 | 72 | 92 | 112 | | | | | |

8프레임 투구 :2
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | x | x | 2|/ | x | x | 2 | | |
| | 20 | 50 | 72 | 92 | 112 | 134 | | | | |

8프레임 투구 :8
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | x | x | 2|/ | x | x | 2|/ | | |
| | 20 | 50 | 72 | 92 | 112 | 134 | 154 | | | |

9프레임 투구 :1
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | x | x | 2|/ | x | x | 2|/ | 1 | |
| | 20 | 50 | 72 | 92 | 112 | 134 | 154 | 165 | | |

9프레임 투구 :9
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | x | x | 2|/ | x | x | 2|/ | 1|/ | |
| | 20 | 50 | 72 | 92 | 112 | 134 | 154 | 165 | | |

10프레임 투구 :2
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | x | x | 2|/ | x | x | 2|/ | 1|/ | 2 |
| | 20 | 50 | 72 | 92 | 112 | 134 | 154 | 165 | 177 | |

10프레임 투구 :8
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | x | x | 2|/ | x | x | 2|/ | 1|/ | 2|8 |
| | 20 | 50 | 72 | 92 | 112 | 134 | 154 | 165 | 177 | |

10프레임 투구 :2
| NAME | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 |
| aaa | 1|/ | x | x | x | 2|/ | x | x | 2|/ | 1|/ | 2|8|2|
| | 20 | 50 | 72 | 92 | 112 | 134 | 154 | 165 | 177 | 189 |
```
22 changes: 10 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
plugins {
id 'org.springframework.boot' version '2.6.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'java'
}

group = 'camp.nextstep'
version = '1.0.0'
sourceCompatibility = '11'

repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'com.h2database:h2'
testImplementation 'org.assertj:assertj-core:3.22.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'com.github.woowacourse-projects:mission-utils:1.0.0'
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}

tasks.named('test') {
test {
useJUnitPlatform()
}
66 changes: 66 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 📌 핵심 기능:

# 👩‍💻프로그램 동작 흐름
- [x] 플레이어의 이름을 입력받는다.
- 프레임투구 입력, 출력을 9번 반복한다. (1~9 프레임까지)
- 10번 프레임투구를 입력받고 출력한다..



# 기능 구현 목록
## 🖨️ 입출력 기능

### 입력 기능

- 플레이어 이름 입력받는 기능
- ⚠️예외 검증: 플레이어 이름 입력 형식
- [x] 공백이 아닌지
- [x] 한글이 아닌지

- ⚠️예외 검증: 플레이어 이름 객체
- [x] 3글자인지


- 프레임투구 입력받는 기능
- ⚠️예외 검증: 프레임투구 입력 형식
- [ ] 공백이 아닌지
- [ ] 숫자인지
- [ ] integer 범위 내의 숫자인지

- ⚠️예외 검증: 프레임투구 객체
- [ ] 0~10 범위의 숫자인지


### 출력 기능

- [ ] 투구별 점수판을 출력하는 기능

## 🏃‍♀️ 프로그램 진행 기능
- [ ] 플레이어 이름을 입력받아 생성한다.
- [ ] 점수판을 초기화 한다.
- [ ]


# ✅ 체크할 점
-[ ]
-[ ]

# 🛠 리팩토링 목록
## 요구사항
- [ ] indent (2)
- [ ] 메서드 길이 (15)
- [ ] 단위 테스트 모두 됐는지 확인
## 그 외
- [ ] 컨트롤러 메소드 네이밍 정리 및 분리 개선
- [ ] 숫자 리터럴 상수화
- [ ] 일급 컬렉션 필요 부분 확인
- [ ] 원시값 포장 확인
---
- [ ] 부생성자가 있는 경우 생성자의 접근제어자가 private인지
- [ ] 객체 생성이 불필요한 경우 private 생성자가 있는지
- [ ] 각 클래스의 책임 범위 위반한 것 없는지 점검하기
- [ ] 각 클래스 메소드 순서 점검하기
- [ ] 이해를 위한 코드 전반의 공백 추가
- [ ] 테스트 코드 리팩토링
- [ ] getter 리스트 레퍼런스에 unmodifaible 추가
----
15 changes: 15 additions & 0 deletions src/main/java/bowling/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package bowling;

import bowling.view.InputView;
import bowling.view.printer.ConsolePrinter;
import bowling.view.printer.Printer;
import bowling.view.reader.ConsoleReader;
import bowling.view.reader.Reader;

public class Application {
public static void main(String[] args) {
Reader reader = new ConsoleReader();
Printer printer = new ConsolePrinter();
InputView inputView = InputView.of(reader, printer);
}
}
10 changes: 10 additions & 0 deletions src/main/java/bowling/common/Symbol.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package bowling.common;

public class Symbol {
private Symbol() {
}

public static final String HYPHEN = "-";

public static final String COMMA = ",";
}
70 changes: 70 additions & 0 deletions src/main/java/bowling/controller/BowlingController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package bowling.controller;

import bowling.domain.Ball;
import bowling.domain.FrameBoard;
import bowling.domain.PlayerName;
import bowling.view.InputView;
import bowling.view.OutputView;
import java.util.function.Supplier;

public class BowlingController {
private final InputView inputView;
private final OutputView outputView;

public BowlingController(InputView inputView, OutputView outputView) {
this.inputView = inputView;
this.outputView = outputView;
}

public void run() {
PlayerName playerName = inputView.inputPlayerName();
FrameBoard frameBoard = FrameBoard.init(playerName);
outputView.printBoard(frameBoard);

playFrames(frameBoard);
}

private void playFrames(FrameBoard frameBoard) {
int frameIndex = 0;

while (!frameBoard.hasEmptyFrame()) {
playFrame(frameBoard, frameIndex);
frameIndex++;
}

playBonusBall(frameBoard);
}

private void playBonusBall(FrameBoard frameBoard) {
playFrame(frameBoard, 9);
if (frameBoard.needLastFrameBonus()) {
Ball bonusBall = inputView.inputBall(9);
frameBoard.applyBonusBall(bonusBall);
outputView.printBoard(frameBoard);
}
}

private void playFrame(FrameBoard frameBoard, int frameIndex) {
frameIndex = frameBoard.getNextFrameIndes();
Ball firstBall = inputView.inputBall(frameIndex);
frameBoard.applyFirstBallOf(frameIndex, firstBall);
outputView.printBoard(frameBoard);

if (!firstBall.isStrike()) {
Ball secondBall = inputView.inputBall(frameIndex);
frameBoard.applySecondBallOf(frameIndex, secondBall);
outputView.printBoard(frameBoard);
}


}

private <T> T readWithRetry(Supplier<T> supplier) {
try {
return supplier.get();
} catch (IllegalArgumentException e) {
outputView.printExceptionMessage(e.getMessage());
return readWithRetry(supplier);
}
}
}
Loading