Skip to content

Commit 80c0ddf

Browse files
committed
refactor: MoveCount 클래스의 이름을 더 명확한 TryCount 로 변경
1 parent 73dd335 commit 80c0ddf

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/main/java/controller/Race.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import domain.CarDto;
77
import domain.Cars;
8-
import domain.MoveCount;
8+
import domain.TryCount;
99
import domain.Names;
1010
import domain.Winners;
1111
import domain.WinnersDto;
@@ -17,16 +17,16 @@ public void startGame() {
1717
Names names = InputView.inputCarNames();
1818
Cars cars = Cars.from(names);
1919

20-
MoveCount moveCount = InputView.inputMoveCount();
20+
TryCount tryCount = InputView.inputMoveCount();
2121

22-
startRace(cars, moveCount);
22+
startRace(cars, tryCount);
2323

2424
printWinners(cars);
2525
}
2626

27-
private void startRace(Cars cars, MoveCount moveCount) {
27+
private void startRace(Cars cars, TryCount tryCount) {
2828
OutputView.printResultMessage();
29-
for (int i = 0; i < moveCount.toInt(); i++) {
29+
for (int i = 0; i < tryCount.toInt(); i++) {
3030
moveCars(cars);
3131
printCars(cars);
3232
}

src/main/java/domain/MoveCount.java renamed to src/main/java/domain/TryCount.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
package domain;
22

3-
public class MoveCount {
3+
public class TryCount {
44
private static final String NUMBER_FORMAT_ERROR_MESSAGE = "숫자만 입력할 수 있습니다.";
55
private static final String NUMBER_RANGE_ERROR_MESSAGE = "시도 회수는 1 이상으로 입력해야 합니다.";
66

7-
private static final int MINIMUM_MOVE_COUNT = 1;
7+
private static final int MINIMUM_TRY_COUNT = 1;
88

9-
private final int moveCount;
9+
private final int tryCount;
1010

11-
private MoveCount(int moveCount) {
12-
validateRange(moveCount);
13-
this.moveCount = moveCount;
11+
private TryCount(int tryCount) {
12+
validateRange(tryCount);
13+
this.tryCount = tryCount;
1414
}
1515

16-
public static MoveCount from(String moveCount) {
16+
public static TryCount from(String tryCount) {
1717
try {
18-
int convertedMoveCount = Integer.parseInt(moveCount);
19-
return new MoveCount(convertedMoveCount);
18+
int convertedTryCount = Integer.parseInt(tryCount);
19+
return new TryCount(convertedTryCount);
2020
} catch (NumberFormatException e) {
2121
throw new IllegalArgumentException(NUMBER_FORMAT_ERROR_MESSAGE);
2222
}
2323
}
2424

2525
public int toInt() {
26-
return this.moveCount;
26+
return this.tryCount;
2727
}
2828

29-
private void validateRange(int moveCount) {
30-
if (moveCount < MINIMUM_MOVE_COUNT) {
29+
private void validateRange(int tryCount) {
30+
if (tryCount < MINIMUM_TRY_COUNT) {
3131
throw new IllegalArgumentException(NUMBER_RANGE_ERROR_MESSAGE);
3232
}
3333
}

src/main/java/view/InputView.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import java.util.stream.Collectors;
55

66
import camp.nextstep.edu.missionutils.Console;
7-
import domain.MoveCount;
7+
import domain.TryCount;
88
import domain.Name;
99
import domain.Names;
1010

@@ -25,12 +25,12 @@ public static Names inputCarNames() {
2525
}
2626
}
2727

28-
public static MoveCount inputMoveCount() {
28+
public static TryCount inputMoveCount() {
2929
OutputView.printInputMoveCount();
3030

3131
try {
3232
String input = Console.readLine();
33-
return MoveCount.from(input);
33+
return TryCount.from(input);
3434
} catch (IllegalArgumentException e) {
3535
OutputView.printErrorMessage(e.getMessage());
3636
return inputMoveCount();

0 commit comments

Comments
 (0)