Skip to content

[장지훈_BackEnd] 1주차 과제 제출합니다.#2

Open
Superpinoiman wants to merge 11 commits intoBCSDLab-Edu:mainfrom
Superpinoiman:main
Open

[장지훈_BackEnd] 1주차 과제 제출합니다.#2
Superpinoiman wants to merge 11 commits intoBCSDLab-Edu:mainfrom
Superpinoiman:main

Conversation

@Superpinoiman
Copy link
Copy Markdown

테스트 모두 확인하고 올립니다.
image

Copy link
Copy Markdown
Collaborator

@dh2906 dh2906 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 +25
static class Car {
String name;
int score = 0;
boolean winner = true;

Car(String name) {
this.name = name;
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Application.javaCar 클래스가 종속되는 것보단 파일을 추가로 만들어서 분리하는 것은 어떻게 생각하시나요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

클래스를 사용하는 의도에 맞게 유지,보수가 편해지도록 따로 분리하여 코딩하는 습관이 있어야 할 것 같다고 생각하게 되었습니다. 참고하겠습니다.

Comment on lines +18 to +20
String name;
int score = 0;
boolean winner = true;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  1. 접근 제어자를 지정하지 않으면 무슨 일이 생길까요??
  2. 자동차 경주를 시작하지도 않았는데 기본값으로 winnertrue로 둔 이유가 있으신가요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

접근제어자를 지정하지 않으면 같은 패키지 안에서만 접근이 가능해집니다. 어떤 의도로 클래스를 만들었는지 알아보기 어려워질 수 있겠네요. 참고하겠습니다. winner는 실행 마지막에 score 비교 후 낮은 객체의 winner를 False로만 바꾸면 간단할 것 같다고 생각해서 미리 true로 설정했는데 이것도 경주시작도 안했는데 winner라면 말이 안되네요. 참고하겠습니다.

}
}

private static boolean nameAgain(ArrayList<Car> Cars){
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  1. private static 메소드는 무슨 특징을 지닐까요?
  2. 이렇게 지정한 이유가 있으신가요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

해당 클래스 안에서만 호출이 가능하고 객체 없이 호출이 가능한 특징이 있습니다. 그리고 여기 클래스 안에서만 사용하고 따로 객체 없이 기능을 하는 메소드라는 특징이 있습니다. 따로 이유는 없이 유틸 메소드를 만들려고 static으로 지정했습니다.

}

private static boolean nameAgain(ArrayList<Car> Cars){
Set<String> nameSet = new HashSet<>();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Set 자료구조의 특징은 무엇일까요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

순서가 없어 중복을 허용하지 않습니다.

Comment on lines +46 to +48
} else {
Cars.add(new Car(names[i]));
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

별 차이는 없지만, if 문에서 조건이 걸린다면 어차피 예외를 발생해서 프로그램을 종료하므로 else 문은 명시하지 않아도 될 것 같아요!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

더욱 깔끔하게 되네요. 참고하겠습니다.

for (int i = 0; i < Cars.size(); i++){
random = Randoms.pickNumberInRange(0, 9);
if(random >= 4){
Cars.get(i).score++;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

이런 식으로 객체의 멤버 변수를 직접 접근하는 방식은 지양해주세요!
전용 메소드를 하나 만들어서 이를 호출하는 방식을 채택해주세요

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

이것 또한 클래스를 사용한 의도랑 맞지 않네요. 메소드를 만들도록 참고하겠습니다.

}
}
}
} No newline at end of file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

깃허브에 코드를 올릴때는 맨 마지막 라인에 공백이 들어와야 해요!

자료 참고바랍니당

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

참고하겠습니다. 피드백 공부 많이 됐습니다 감사합니다.

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