Skip to content

2021년 8월 17일에 리뷰할게요~ #2

@KwakTaeMin

Description

@KwakTaeMin

private String name;

  • 객체지향 생활체조 : 모든 원자 값은 포장하라
  • String name 을 Name 클래스로 만들어 보세요~

for (int i = 0; i < attempt_count; i++) {
Random random = new Random();
// 0~10사이의 난수
int random_number = random.nextInt(10);
if(random_number > 5){
// 해당 move_count 값을 어떻게 유지하고 있는가.
move_count++;
}
}

  • 객체지향 생활체조 : indent 2이상

private int move_count;

  • camel case하지 않아요. Google java style guide 읽어보세요(플레이그라운드 요구사항에 있는 것 같아요)

public void printNames(int attempt_count) {

  • 이름을 프린트하는 메소드인지, 움직이는걸 시도하는 메소드인지 모르겠어요
  • 메소드가 한가지만 작동하도록 구현해보세여

public List<Car> getCars() {

public static Cars Start(){

  • Start() 메소드가 시작하는 메소드인건지, 자동차 이름을 입력하는 건지 자동차들을 만드는 클래스인건지 모르겠어요 메소드가 한가지일만 하도록 해봐요
  • 모든 메소드는 소문자로 시작해요. Google java style guide 읽어보세요~

public static int Racing() {

  • 모든 메소드는 소문자로 시작해요. Google java style guide 읽어보세요~
  • Racing의미가 경주인데 시도 횟수만 입력하는 메소드같네요 다른 사람이 보았을 때 햇갈릴 것 같아요

public static void printResult(List<Car> cars) {
List<String> winner_list = new ArrayList<>();
String winner = null;
int max_count = 0;
for (int i = 0; i < cars.size(); i++) {
String current_car = cars.get(i).getName();
int last_count = cars.get(i).getMove_count();
if (last_count > max_count) {
winner = current_car;
max_count = last_count;
}
if (max_count == last_count) {
winner_list.add(winner);
}
}
System.out.println("실행 결과");
for (int i = 0; i < winner_list.size(); i++) {
System.out.print(winner_list.get(i) + " ");
}
System.out.print("가 최종 우승했습니다.");
}

  • printResult 메소드는 10줄 이내로 작성해주세요
  • indent 2이상이네요 수정해주세요~
  • 결과를 판별하는 메소드이기도하고, 프린트도 하고 우승자도 찾고 우승자도 프린트하는 메소드 같아요 분할하여 관리하면 좋을 것 같아요

Cars cars = InputView.Start(); // List<Car> Car객체를 담고 있는 Cars 객체 생성
int attempt_count = InputView.Racing(); // 게임 시도 횟수
// 시도한 횟수만큼 게임을 돈다.
for (int attempt_index = 0; attempt_index < attempt_count; attempt_index++) {
cars.printNames(attempt_index + 1);
}
List<Car> result_car = cars.getCars();
ResultView.printResult(result_car);

고민하구 열심히 한 것 같은데 테스트 코드가 하나도 없네요..ㅜㅜ
잘하고 있는데 끝까지 해봐요. 급하게 생각하지말고 안되고 안깨우쳐지는게 당연합니다.
끝까지 해보세요~
할 수 있어요!
질문은 이슈사항에 남겨주세요~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions