Skip to content

[김용진_BackEnd] 1주차 과제 제출합니다.#44

Open
Rlayd36 wants to merge 20 commits intoBCSDLab-Edu:mainfrom
Rlayd36:main
Open

[김용진_BackEnd] 1주차 과제 제출합니다.#44
Rlayd36 wants to merge 20 commits intoBCSDLab-Edu:mainfrom
Rlayd36:main

Conversation

@Rlayd36
Copy link

@Rlayd36 Rlayd36 commented Mar 24, 2025

No description provided.

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.

고생하셨습니다!
변수명이나 개행, 주석같은 부분은 계속 코드를 치시다보면 익숙해질겁니다
이번주에 객체지향 관련 학습을 하시면서 Car 클래스, Racing 클래스 등 다양한 역할을 가진 클래스로 구분하는 연습을 해보시면 좋을 것 같아요 :) 👍

Comment on lines +5 to +6
// import java.util.LinkedList;
// import java.util.Queue;

Choose a reason for hiding this comment

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

사용하지 않는 코드들은 삭제해주세요!

public class Application {
public static void main(String[] args) {
// TODO: 프로그램 구현
String carsStr = carInput();

Choose a reason for hiding this comment

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

carStr이라는 변수명은 자료형이 들어가 권장되지 않는 변수명입니다!

// 여기까지 입력

Game(carsList, tryNum);

Choose a reason for hiding this comment

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

이런 개행은 지워주면 깔끔할 것 같아요


}

public static String carInput() { // 사용자 입력 (자동차 목록)

Choose a reason for hiding this comment

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

static으로 메서드를 선언하셨는데 이렇게 되면 어떻게 동작할까요?
객체지향에서 static 사용은 객체지향에서 어떻게 다가올까요?

Comment on lines +29 to +32
public static String[] carSplit(String carsStr) { // 사용자 한테 입려받은 문자열 "," 기준으로 찢기
String[] carsList = carsStr.split(",");
return carsList;
}

Choose a reason for hiding this comment

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

바로 return 해줘도 될 것 같아요

}

public static void errCheck_carsList(String[] carsList) throws IllegalArgumentException{ // 입력한 차 이름이 5글자 이하인지 체크
for (String s : carsList) {

Choose a reason for hiding this comment

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

s 보다는 carName 이라는 변수명은 어떨까요?

return tryNum;
}

public static void errCheck_carsList(String[] carsList) throws IllegalArgumentException{ // 입력한 차 이름이 5글자 이하인지 체크

Choose a reason for hiding this comment

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

메서드명에 _를 추가하셨는데 다른 메서드들과 다른 이유가 있을까요?
validate 라는 네이밍은 어떨까요?

Comment on lines +84 to +89
public static int[] move(String[] carsList, int[] moveCnt) {
for (int i = 0; i < carsList.length; i++) {
moveCnt = randomMove(moveCnt, i);
}
return moveCnt;
}

Choose a reason for hiding this comment

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

이렇게 되면 각 자동차들의 움직임에 대한 관리가 어려울 것 같은데 어떻게 생각하시나요?
이번주 객체지향을 공부하시면서 Car 클래스로 분리할 방법에 대해 고민해보면 좋을 것 같아요!

}

public static String[] checkWinner(String[] carsList, int[] moveCnt) {
/*

Choose a reason for hiding this comment

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

이 부분도 더 이상 사용하지 않으면 삭제해주세요!

return moveCnt;
}

public static void printEachMove(String[] carsList, int[] moveCnt){

Choose a reason for hiding this comment

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

코드의 depth가 3을 넘어가는것 같아요

Copy link
Author

Choose a reason for hiding this comment

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

알려주신 부분들 확인해서 리팩토링에 반영해보겠습니다.!

Copy link

@Choon0414 Choon0414 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!
기능 단위로 메서드를 분리하려고 많이 노력하신 것 같아요.

처음이라 많이 어려우셨을 텐데, 앞으로 천천히 교육을 들으면서 코드를 고쳐나가면 실력이 금방 느실 것 같습니다.


}

public static String carInput() { // 사용자 입력 (자동차 목록)

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 < moveCnt.length; i++) {
if(moveCnt[i] == maxValue) {
winner[cnt] = carsList[i];
cnt++;

Choose a reason for hiding this comment

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

두 분기점에서 공통으로 수행하는 부분은 if문 바깥에 구현해주는 건 어떤가요?

printEachMove(carsList, moveCnt);
}

String[] winner = checkWinner(carsList, moveCnt);

Choose a reason for hiding this comment

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

우승자 계산 부분을 메서드로 따로 분리해보는 건 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

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

리뷰해주신 메서드 명, if문 구현, 매서드 분리 리팩토링 해보겠습니다.!

@skdud0629
Copy link

분발해라

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.

4 participants