-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2단계 - 자동차 경주 리팩터링] 저문(유정훈) 미션 제출합니다. #587
Changes from 1 commit
288fe2e
d4925b0
3eb2528
a952b6a
4e18b9e
8801430
6425dcf
e5f96b4
9d197c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package racing.domain; | ||
|
||
public interface NumberGenerator { | ||
|
||
int generate(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ public RacingGame(CarGroup group, RandomNumberGenerator randomNumberGenerator) { | |
|
||
//TODO: 테스트 | ||
public void race() { | ||
carGroup.race(isMovable()); | ||
carGroup.race(numberGenerator); | ||
} | ||
|
||
public RacingResult produceRacingResult() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 테스트할 수 있어보입니다. |
||
|
@@ -28,8 +28,4 @@ public RacingResult produceRacingResult() { | |
|
||
return new RacingResult(history); | ||
} | ||
|
||
private boolean isMovable() { | ||
return (numberGenerator.generate() >= MOVABLE_CONDITION); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MOVABLE_CONDITION이 사용되지 않는 상수가 되었네요. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package racing.domain; | ||
|
||
public class RandomNumberGenerator { | ||
public class RandomNumberGenerator implements NumberGenerator { | ||
|
||
@Override | ||
public int generate(){ | ||
return (int)(Math.random() * 10); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 범위 테스트가 가능해보입니다. |
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package racing.domain; | ||
|
||
public class MovableNumberGenerator implements NumberGenerator { | ||
|
||
@Override | ||
public int generate() { | ||
return 4; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package racing.domain; | ||
|
||
public class NonMovableNumberGenerator implements NumberGenerator { | ||
|
||
@Override | ||
public int generate() { | ||
return 0; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NumberGenerator를 구현하여 모든 자동차가 이동했는지를 테스트할 수 있어보입니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아래 getCars() 메서드보다 검증 메서드 setUp 메서드가 더 중요해보입니다-!