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

bgg01590 #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

bgg01590 #7

wants to merge 1 commit into from

Conversation

bgg01590
Copy link

@bgg01590 bgg01590 commented Jan 26, 2024

늦제출합니다 (_ _),,
통커밋도 죄송합니다 ㅁㅁ

@bgg01590 bgg01590 changed the title 늦어서 죄송합니다,, bgg01590 Jan 26, 2024
Copy link

@KYankee6 KYankee6 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다

return this.answer;
}

public String getAnswer() {

Choose a reason for hiding this comment

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

image 자바의 메서드 접근 제한자에 따른 선언의 순서를 지켜주세요.


public void initAnswer(){
this.answer = generateAnswer();
System.out.println(this.answer);

Choose a reason for hiding this comment

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

생성된 난수 테스트 출력 용도로 보이는데 맞을까요?

Copy link
Owner

@Jaeyoung22 Jaeyoung22 left a comment

Choose a reason for hiding this comment

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

주현님, 코드 잘 읽었습니다!

구조도 깔끔하고 네이밍도 좋아서 잘 읽히는 코드였습니다.

몇 가지 커멘트 남겼으니 확인해주시면 감사하겠습니다!

1주차 고생하셨습니다~!

import camp.nextstep.edu.missionutils.Randoms;

public class AnswerGenerator {
private String answer;
Copy link
Owner

Choose a reason for hiding this comment

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

~~or, ~~er 등 역할의 이름으로 끝나는 클래스는 보통 util성 클래스가 많은 것으로 알고 있습니다.

generateAnswer()를 static 함수로 두고, String answer = AnswerGenerator.generate() 등으로 사용하는 방법은 어떨까요?

굳이 answer를 필드로 가지고 있지 않아도 될 것 같습니다!

private final BaseballRuler baseballRuler;

public Baseball() {
this.answerGenerator = new AnswerGenerator();
Copy link
Owner

Choose a reason for hiding this comment

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

좋네요! 아직 스프링을 사용하지는 않지만 Baseball 생성자의 파라미터로 두 클래스를 두면 의존성 주입이 가능할 것 같습니다!

int balls=0;
for (int i = 0; i < 3; i++) {
if (answer.contains(String.valueOf(input.charAt(i)))
&& answer.charAt(i) != input.charAt(i)) {
Copy link
Owner

Choose a reason for hiding this comment

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

이 로직이 위의 countStrikes 내부의 핵심 로직과 겹쳐서 보통 합치는 것으로 생각했는데, 이렇게 분리를 해도 깔끔한 것 같네요 :+1

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.

3 participants