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

[숫자 야구 게임] 이은지 미션 제출합니다. #604

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

oeunji
Copy link

@oeunji oeunji commented Aug 28, 2024

No description provided.

Feat : 난수 생성 클래스 구현
Feat : 입력 클래스 구현
Feat : 에러 관리 클래스 구현
Feat : 숫자 비교 클래스 구현
Feat : 게임 진행 클래스 구현
@oeunji oeunji changed the title [숫자 야구 게임] 이은 미션 제출합니다. [숫자 야구 게임] 이은지 미션 제출합니다. Aug 28, 2024
Copy link

@dradnats1012 dradnats1012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니당

Comment on lines +17 to +29
if (strike == 0 && ball == 0) {
System.out.println("낫싱");
} else {
System.out.println(ball + "볼 " + strike + "스트라이크");
}

// 3 스트라이크인 경우 게임 종료
if (strike == 3) {
printGameOverMessage();
gameOver = true;
} else {
gameOver = false;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

숫자 비교하는 메서드랑 분리하는게 좋을 것 같아요

Comment on lines +9 to +11
List<Integer> randomNumber = computer.getRandomNumber();
player.playerInputNumber(); // 숫자 입력
List<Integer> playerNumber = player.getInputNumber();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다른 곳에서 숫자를 만들고 매개변수로 넘겨주는건 어떨까요?

Comment on lines +19 to +34
do {
isDuplicate = false;
for (int i = 0; i < 3; i++) {
int num = Randoms.pickNumberInRange(1, 9); // 1 ~ 9 난수 생성
if (!numbers.contains(num)) {
numbers.add(num);
} else {
isDuplicate = true;
break; // 중복이 발생하면 break -> 다시 시도
}
}

if (isDuplicate) {
numbers.clear();
}
} while (isDuplicate || numbers.size() < 3);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depth가 너무 깊은것 같아요 분리해줘요

Comment on lines +43 to +45
public void resetRandomNumber() {
this.randomNumber = generateRandomNumber();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generateNewRandomNumber() 는 어때요

Comment on lines +14 to +37
public void play() {
boolean continuePlaying = true;

while (continuePlaying) {
compareNumber.compareNumber(player, computer);

if (compareNumber.isGameOver()) {
System.out.println("게임을 새로 시작하려면 1, 종료하려면 2를 입력하세요.");
String replayInput = player.inputReplay();

if ("1".equals(replayInput)) {
// 게임 재시작
computer.resetRandomNumber(); // 새로운 난수 생성
} else if ("2".equals(replayInput)) {
// 게임 종료
continuePlaying = false;
} else {
// 잘못된 입력 처리
System.out.println("잘못된 입력입니다. 게임을 종료합니다.");
continuePlaying = false;
}
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

한 메서드안에 너무 많은게 들어가있는것 같아요
분리해줘요

import java.util.regex.Pattern;

public class InputException {
private static final String NOT_NUMBER = "숫자가 아닙니다.";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static final 을 붙이면 무슨일이 일어날까요

Comment on lines +12 to +14
public Player() {
this.inputNumber = new ArrayList<>();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

생성자에서 이걸 해주는 이유가 궁금해요

Comment on lines +32 to +35
public String inputReplay(){
String inputReplay = Console.readLine();
return inputReplay;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이걸 Player 클래스에서 받는 이유가 궁금해요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants