Skip to content

hyungin0505/week2 과제 제출 #66

Open
hyungin0505 wants to merge 9 commits intomainfrom
hyungin0505/week2
Open

hyungin0505/week2 과제 제출 #66
hyungin0505 wants to merge 9 commits intomainfrom
hyungin0505/week2

Conversation

@hyungin0505
Copy link
Member

  • car, race, service, serviceimpl, view 폴더로 나눠서 기능을 분산시켰습니다

  • car/Car.java
    • name, distance를 public에서 private으로 바꾸고 getter, setter 정의해서 사용했습니다
    • 기존에는 tryMove(ranNum)로 랜덤값을 인자로 넣었지만 tryMove()Car 객체 내에서 랜덤값 뽑아서 움직입니다
      // 기존 코드
      public void move(int ranNum) {
          if (ranNum >= 4) {
              this.distance++;
          }
      }
      // 변경된 코드
      public void tryMove() {
          Random random = new Random();
          int ranNum = random.nextInt(10); 
      
          if (ranNum >= 4) {
              this.distance++;
          }
      }
  • race/Race.java
    • cars 동적 배열, maxDistance도 private으로 바꿨습니다
      private final ArrayList<Car> cars;
      private int maxDistance = 0;
    • 자동차 이름 저장 시 trim()으로 문자열 앞뒤 공백을 제거합니다 (공백 제거 후 이름 길이 검증)
      Car car = new Car(carName.trim());
    • max() 메소드 따로 정의 없이 Math.max()로 바꿨습니다
      maxDistance = Math.max(car.getDistance(), maxDistance);
    • 우승자 출력, 자동차 위치 출력은 RaceResult로 따로 뺐습니다
  • view/RaceResult.java
    • printWinners 메소드에서 최종 우승자를 출력합니다
    • printCarPosition 메소드에서 자동차 객체 하나의 namedistance를 사용해 해당 자동차의 위치를 출력합니다
  • serviceimpl/CountInputServiceImpl.java
    • 시도 횟수로 정수값이 입력되지 않았을 때의 예외 처리 추가했습니다

@hyungin0505 hyungin0505 linked an issue Apr 6, 2025 that may be closed by this pull request
Copy link

@glucosei glucosei left a comment

Choose a reason for hiding this comment

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

전부 왜 그렇게 했는지 이해가 되어서 어떻게 피드백을 해야할지 모르겠네요... 제 식견으로는 고칠 거리가 안 보입니다! 수고하셨어요!

Copy link

@dp44rk dp44rk left a comment

Choose a reason for hiding this comment

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

역시 InputView 를 따로 나누신부분 인상깊게 보았습니다.
접근제어자나 키워드들도 적절하게 잘 사용하신것 같습니다

Copy link

Choose a reason for hiding this comment

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

subject에 명시되어있는 대로 camp.nextstep.edu.missionutils의 메소드들을 사용하는것이 좋을것 같습니다

Choose a reason for hiding this comment

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

객체지향적으로 굉장히 깔끔하게 리팩토링 하신 것 같습니다!

@hyungin0505 hyungin0505 linked an issue May 19, 2025 that may be closed by this pull request
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