-
Notifications
You must be signed in to change notification settings - Fork 429
Step3 - 볼링 점수판(리팩토링) 리뷰 요청드립니다. #44
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
Changes from all commits
05ca365
376137a
c17d266
dc3d85b
dca8851
293fd68
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package domain; | ||
|
||
import domain.frame.FrameResult; | ||
|
||
import java.util.Objects; | ||
|
||
import static domain.frame.FrameResult.UNFINISHED_SCORE; | ||
import static domain.Pins.STRIKE_PINS; | ||
|
||
public class Score { | ||
private static final int DEFAULT_SCORE = 0; | ||
public static final int UNFINISHED_SCORE = -1; | ||
|
||
private int score; | ||
private int remainingAddition; | ||
|
@@ -20,6 +20,26 @@ public static Score of(int score, int remainingAddition) { | |
return new Score(score, remainingAddition); | ||
} | ||
|
||
public static Score ofDefault() { | ||
return new Score(DEFAULT_SCORE, 0); | ||
} | ||
|
||
public static Score ofUnfinished() { | ||
return new Score(UNFINISHED_SCORE, 0); | ||
} | ||
|
||
public static Score ofMiss(int sumOfPins) { | ||
return new Score(sumOfPins, 0); | ||
} | ||
|
||
public static Score ofSpare() { | ||
return new Score(STRIKE_PINS, 1); | ||
} | ||
|
||
public static Score ofStrike() { | ||
return new Score(STRIKE_PINS, 2); | ||
} | ||
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. 이와 같은 정적 팩토리 메소드 또한 api를 사용하는 입장에서는 유용한 메소드라 생각해요. 👍 |
||
|
||
public Score update(int newScore) { | ||
if (isFullyCalculated() || isUnfinishedScore(newScore)) { | ||
return this; | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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.
저는 이런 상수 값들이 지금과 같이 의존관계가 높은 Pins와 같은 객체에 있는 것이 더 좋다고 생각해요.