Skip to content

[송정민_BackEnd]1주차 과제 제출합니다.#4

Open
song010301-cloud wants to merge 1 commit intoBCSDLab-Edu:mainfrom
song010301-cloud:main
Open

[송정민_BackEnd]1주차 과제 제출합니다.#4
song010301-cloud wants to merge 1 commit intoBCSDLab-Edu:mainfrom
song010301-cloud:main

Conversation

@song010301-cloud
Copy link
Copy Markdown

@song010301-cloud song010301-cloud commented Mar 29, 2026

과제를 진행하면서 어려운 점 보다는 처음 테스트를 실행을 하려고 하는데 자꾸 에러가 발생해 어떤 문제지 찾다가 캐시무효화를 시키니 정상작동을 하는 것을 알 수 있었습니다.
1주차 동아리 과제

@song010301-cloud song010301-cloud changed the title [송정민_BackEnd]N주차 과제 제출합니다. [송정민_BackEnd]1주차 과제 제출합니다. Mar 29, 2026
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.

고생하셨습니다!
레이싱 게임의 과정이 몇 단계로 되어있는지 생각해보시고 각 단계를 메소드로 분리해주세요!

- 자동차 이릅 입력받기
- 시도할 횟수 입력받기
- 입력받은 자동차 이름이 5자 이하인지 확인하기
- 숫자에 따라 자동차가 전진/후진 할지 결정하기
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.

어랏 후진도 있었나요??

Comment on lines +19 to +26
if (names[i].isEmpty()) // 빈값 (예: pobi,,woni)
{
throw new IllegalArgumentException();
}
if (names[i].contains(" ")) // 이름에 공백 포함 (예: pobi, woni)
{
throw new IllegalArgumentException();
}
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.

Suggested change
if (names[i].isEmpty()) // 빈값 (예: pobi,,woni)
{
throw new IllegalArgumentException();
}
if (names[i].contains(" ")) // 이름에 공백 포함 (예: pobi, woni)
{
throw new IllegalArgumentException();
}
if (names[i].isBlank())
{
throw new IllegalArgumentException();
}

이런 식으로 통합할 수도 있어 보여요!
isEmptyisBlank의 차이를 찾아보시는걸 추천드립니다.

}
}

// 2. 이름 중복 예외 처리 (이중 for문으로 하나씩 비교)
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.

컬렉션 중에 중복을 허용하지 않는 자료구조가 있습니다!
찾아보시고 적용도 해보시면 좋을 것 같아요.

throw new IllegalArgumentException();
}

int[] position = new int [names.length];
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. 어떻게 묶을까요?

{
for (int j = 0 ; j < names.length; j++)
{
int randomnum = camp.nextstep.edu.missionutils.Randoms.pickNumberInRange(0,9);
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.

3번 라인처럼 import를 사용하면 랜덤 값을 꺼내기 위한 메소드를 사용하는데 이렇게 긴 코드가 필요하지 않을거에요

Comment on lines +66 to +67
int randomnum = camp.nextstep.edu.missionutils.Randoms.pickNumberInRange(0,9);
if (randomnum >= 4)
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.

Suggested change
int randomnum = camp.nextstep.edu.missionutils.Randoms.pickNumberInRange(0,9);
if (randomnum >= 4)
if (pickNumberInRange(0,9) >= 4)
  1. 바로 이런 식으로 한다면 randomnum이라는 변수는 필요없지 않을까요?

  2. 자바에서는 변수명을 카멜케이스로 사용하는 것이 컨벤션 입니다. 자바의 네이밍 컨벤션에 대해서도 찾아보시는걸 추천드려요!

Comment on lines +73 to +76
for(int k = 0; k < position[j]; k++)
{
System.out.print("-");
}
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.

String.repeat() 메소드를 사용한다면 반복문이 필요없어져요!

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