Skip to content

김남홍_BackEnd 2주차과제 제출#11

Open
namongster wants to merge 9 commits intoBCSDLab-Edu:mainfrom
namongster:main
Open

김남홍_BackEnd 2주차과제 제출#11
namongster wants to merge 9 commits intoBCSDLab-Edu:mainfrom
namongster:main

Conversation

@namongster
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@BaeJinho4028 BaeJinho4028 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 +7 to +10
public void forward(String[] cars){
for (int i =0;i < cars.length; i++){

}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

해당 코드를 남겨놓은 이유가 있을까요?

Comment on lines +70 to +77


}
}




Copy link
Copy Markdown

Choose a reason for hiding this comment

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

불필요한 공백들은 제거해주세요:)

}
}

public static void main(String[] args) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

main()에서 입력, 검증, 게임 진행, 우승자 출력까지 모두 담당하고 있어 역할별 메서드로 나누면 가독성이 더 좋아질 것 같습니다.

for (int j = 0; j < cars.length; j++) {
int num = Randoms.pickNumberInRange(0, 9);
System.out.print(cars[j] + " : ");
if (num >= 4) {race[j] += "-";System.out.println(race[j]);count[j]++;}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

한 줄에 여러 동작이 함께 들어가 있어, 줄을 나누면 읽기 훨씬 편해질 것 같습니다.

Comment on lines +41 to +43
String[] race = new String[cars.length];
Arrays.fill(race,"");
int[] count = new int[cars.length];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

자동차 이름과 이동 상태를 각각 배열로 관리하기보다 클래스로 묶으면 데이터 관리가 더 자연스러울 것 같습니다.

@namongster namongster changed the title 김남홍_BackEnd 1주차과제 제출 김남홍_BackEnd 2주차과제 제출 Apr 6, 2026
Copy link
Copy Markdown

@BaeJinho4028 BaeJinho4028 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 +8 to +19
static String[] cars;
static int[] count;
static class player{//자동차 이름 및 경주 순위 클래스
String name;
int counting;

player(String name, int counting){
this.name = name;
this.counting = counting;
}
}

public static void main(String[] args) {

//플레이어 자동차 이름 입력받기
static player[] playerarr;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

전역상태에 의존했을떄의 단점은 무엇일까요?

Comment on lines +10 to 18
static class player{//자동차 이름 및 경주 순위 클래스
String name;
int counting;

player(String name, int counting){
this.name = name;
this.counting = counting;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

데이터를 담는 객체만 추가된 상태라기보다, 자동차가 스스로 상태와 행위를 가지는 구조로 바꾸면 더 객체지향적인 설계가 될 것 같습니다.

Comment on lines +20 to 34
public static void name(){//자동차 이름 입력
System.out.print("경주할 자동차 이름을 입력하세요 (,로 구분하고 5자 이하) : ");
String carsinput = Console.readLine();
String[] cars = carsinput.split(",");
cars = carsinput.split(",");

//이름 예외처리

for(int i =0;i < cars.length;i++){ //5자 이하로
if (cars[i].length() > 5){
for (String car : cars) { //5자 이하로
if (car.length() > 5) {
throw new IllegalArgumentException();
}

if(cars[i].isBlank()){ //빈칸
if (car.isBlank()) { //빈칸
throw new IllegalArgumentException();
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

입력을 받는 메서드가 검증과 상태 저장까지 함께 담당하고 있어 책임이 다소 많이 몰려 있습니다.

Comment on lines 47 to 48
String[] race = new String[cars.length];
Arrays.fill(race,"");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

race 문자열 배열로 출력 상태를 따로 관리하기보다 자동차 객체가 자신의 이동 상태를 표현하도록 하는건 어떨까요

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