Skip to content

[황명하_BackEnd] 2주차 과제 제출합니다#18

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

[황명하_BackEnd] 2주차 과제 제출합니다#18
audgk54587-dev wants to merge 4 commits intoBCSDLab-Edu:mainfrom
audgk54587-dev:main

Conversation

@audgk54587-dev
Copy link
Copy Markdown

실행 중 빌드 오류가 발생합니다. 혼자 힘으로 해보려고 노력했지만 도저히 알 수 없었고 ai에게도 물어봤지만 잘 모르겠습니다. 과제를 완료하지 못해 죄송합니다.

@audgk54587-dev audgk54587-dev changed the title 황명하_BackEnd [황명하_BackEnd] 1주차 과제 제출합니다 Mar 31, 2026
@audgk54587-dev audgk54587-dev changed the title [황명하_BackEnd] 1주차 과제 제출합니다 [황명하_BackEnd] 2주차 과제 제출합니다 Apr 4, 2026
Copy link
Copy Markdown

@ImTotem ImTotem left a comment

Choose a reason for hiding this comment

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

controller, model, view로 패키지를 분리하고 Car의 필드를 private으로 잘 감싼 점은 좋아요 👍

과제 진행 요구사항에 "기능을 구현하기 전 docs/README.md에 구현할 기능 목록을 정리해 추가한다"가 있는데, 파일이 비어 있어요. 구현한 기능들을 정리해서 채워보면 좋겠습니다.

build.gradle Outdated
Comment on lines +15 to +17

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

프로그래밍 요구사항에 "build.gradle 파일을 변경할 수 없고, 외부 라이브러리를 사용하지 않는다"고 되어 있어요. 빌드 에러의 원인이 이 변경과 관련 있을 수 있으니, 되돌리고 다시 확인해보면 좋겠습니다.


import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors; // 1. 이 임포트를 추가하세요!
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

AI가 남긴 지시 주석(// 1., // 2., // 3.)이 코드에 그대로 남아 있어요. 제출 전에 정리해주면 좋겠습니다.

Comment on lines +21 to +32
if (name.contains(" ")) {
throw new IllegalArgumentException("[ERROR] 이름에 공백을 포함할 수 없습니다.");
}
// 3. 빈 문자열(,,) 체크도 안전하게 추가합니다.
if (name.isEmpty()) {
throw new IllegalArgumentException("[ERROR] 이름은 빈 값일 수 없습니다.");
}
}

if (new java.util.HashSet<>(carNames).size() != carNames.size()) {
throw new IllegalArgumentException("[ERROR] 중복된 자동차 이름이 있습니다.");
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

이름 검증(공백, 빈 값, 중복 체크) 로직이 컨트롤러에 있는데, 2주차에서 다룬 "객체의 책임" 관점에서 이 검증이 어느 객체에 있는 게 더 적절할지 한 번 생각해보면 좋을 것 같아요.


public class Car {
private final String name;
private int position=0;
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 메서드의 if(num>=4) 부분도 if 뒤, >= 주변 공백을 맞춰보면 좋겠습니다.

}

public void move(int num){
if(num>=4) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

4라는 숫자가 "전진 기준값"이라는 의미를 담고 있는데, 매직 넘버 대신 상수로 분리하면 어떨까요?

import java.util.List;

public class OutputView {
private static final String Symbol = "-";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

상수(static final)는 Java 컨벤션상 UPPER_SNAKE_CASE로 작성해요. SYMBOL로 바꾸면 좋을 것 같아요.

}

public List<Car> getCars() {
return this.cars;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

내부 리스트를 직접 반환하면 외부에서 수정할 수 있어요. 캡슐화 관점에서 Collections.unmodifiableList()를 같이 알아보면 좋겠습니다.


private List<Car> createCars(List<String> names) {
List<Car> carList = new ArrayList<>();
for(int i=0;i<names.size();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.

향상된 for문을 사용하면 더 간결해질 수 있어요. playRound와 getWinners에서도 같은 패턴이 반복되고 있으니 같이 살펴보면 좋겠습니다.

List<String> winners = racingGame.getWinners();
OutputView.printWinners(winners);
}
} No newline at end of file
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 (new java.util.HashSet<>(carNames).size() != carNames.size()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

import 없이 패키지 경로를 직접 쓰는 방식은 AI가 생성한 코드에서 자주 나타나는 패턴이에요. AI에게 작성을 맡기더라도 제출 전에 꼼꼼히 검토해서, 본인이 이해한 코드인지 한 번 돌아보면 좋겠습니다.

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