Skip to content

[서윤_BackEnd] 2주차 과제 제출합니다.#9

Open
sobigood00 wants to merge 4 commits intoBCSDLab-Edu:mainfrom
sobigood00:main
Open

[서윤_BackEnd] 2주차 과제 제출합니다.#9
sobigood00 wants to merge 4 commits intoBCSDLab-Edu:mainfrom
sobigood00:main

Conversation

@sobigood00
Copy link
Copy Markdown

No description provided.

@sobigood00 sobigood00 changed the title feat: 1주차 백엔드 과제 [서윤_BackEnd] 1주차 백엔드 과제 제출합니다. Mar 30, 2026
@sobigood00 sobigood00 changed the title [서윤_BackEnd] 1주차 백엔드 과제 제출합니다. [서윤_BackEnd] 1주차 과제 제출합니다. Mar 30, 2026

public class Validator {
//이름 입력 검사
public static String validateCarName(String names){
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

현재 호출부에서는 반환값을 사용하지 않고 있어서, 검증만 담당하는 메서드라면 반환형을 조금 더 단순하게 가져갈 수 있을지 고민해봐도 좋을 것 같습니다.

}
//입력을 ,를 기준으로 자른다. 배열로 저장.
String [] nameList = names.split(",",-1);
int name_max = 5;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

상수로 빼려던 의도는 보입니다만, 실제 검증에서는 다시 5를 직접 쓰고 있어서 이 값을 정말 사용할지 아니면 아예 상수 형태로 정리할지 한 번 맞춰보면 좋겠습니다.

if(name.length() > 5) { //2.1 이름 길이
throw new IllegalArgumentException("자동차 이름은 5자 이하로 입력해주세요.");
}
if(name.isBlank() || name.contains(" ")){ //2.2 이름 빈 값/공백
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

바로 위아래 예외는 메시지를 같이 주고 있는데 여기만 비어 있어서, 어떤 입력에서 실패했는지 파악하기 조금 어려울 수 있어 보여요. 이 부분도 같은 톤으로 메시지를 맞춰보면 좋겠습니다.

}
if(name.isBlank() || name.contains(" ")){ //2.2 이름 빈 값/공백
throw new IllegalArgumentException();
}if(!equalNames.add(name)){ //2.3 이름 중복 검사
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

중복 이름까지 예외 처리하고 있는데, 현재 README 요구사항에 포함된 제약인지 한 번 확인해보면 좋겠습니다. 의도한 추가 규칙이 아니라면 스펙보다 강한 제한이 될 수도 있어 보여요.

}

//동작: move 메서드
public int move(){
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

반환값을 사용하는 곳이 보이지 않아서, 이 메서드의 책임이 상태 변경인지 값 반환인지 한 번 더 정리해보면 읽는 입장에서 더 명확해질 것 같아요.

//- Car 객체 생성/레이스 동작
//- 결과 출력
public class Application {
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()에 입력, 검증, 게임 진행, 결과 출력이 모두 들어가 있어서 역할이 조금 큰 느낌이 있습니다. 메서드로 한 단계 더 나누면 흐름이 더 잘 보일 것 같아요.

String names = Console.readLine(); //내부적으로 Scanner.nextLine()과 동일하게 작동
Validator.validateCarName(names);

System.out.println("시도할 회수는 몇회인가요?");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

아주 작은 부분이지만 사용자에게 보여지는 문구라서, 회수보다는 횟수로 맞춰주면 더 자연스러울 것 같아요.

- move, getter 메서드*/

public class Car {
private final String name;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

이름을 final로 두고 상태를 private로 감싼 점은 좋아요. 객체가 가져야 할 값을 비교적 안전하게 관리하려는 의도가 잘 보입니다 👍

@sobigood00 sobigood00 changed the title [서윤_BackEnd] 1주차 과제 제출합니다. [서윤_BackEnd] 2주차 과제 제출합니다. Apr 6, 2026
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