-
Notifications
You must be signed in to change notification settings - Fork 1.1k
๐ 4๋จ๊ณ - ๋ก๋(์๋) #4161
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
base: aj172019
Are you sure you want to change the base?
Changes from all commits
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,10 @@ | ||
package com.nextstep.camp.lotto.domain.exception; | ||
|
||
public class LottoCountCannotBeNegativeException extends RuntimeException { | ||
|
||
private static final String MESSAGE = "๋ก๋ ํฐ์ผ ์๋ 0๋ณด๋ค ์์ ์ ์์ต๋๋ค."; | ||
|
||
public LottoCountCannotBeNegativeException() { | ||
super(MESSAGE); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.nextstep.camp.lotto.domain.exception; | ||
|
||
public class LottoNumberInputRegexException extends IllegalArgumentException { | ||
|
||
private static final String MESSAGE = "๋ก๋ ๋ฒํธ ์ ๋ ฅ ํ์์ด ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค. "; | ||
|
||
public LottoNumberInputRegexException() { | ||
super(MESSAGE); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.nextstep.camp.lotto.domain.vo; | ||
|
||
import java.util.stream.IntStream; | ||
|
||
import com.nextstep.camp.lotto.domain.exception.LottoCountCannotBeNegativeException; | ||
|
||
public class LottoCount { | ||
private final int value; | ||
|
||
private LottoCount(int value) { | ||
validate(value); | ||
this.value = value; | ||
} | ||
|
||
private static void validate(int value) { | ||
if (value < 0) { | ||
throw new LottoCountCannotBeNegativeException(); | ||
} | ||
} | ||
|
||
public static LottoCount of(int intValue) { | ||
return new LottoCount(intValue); | ||
} | ||
|
||
public int getCount() { | ||
return value; | ||
} | ||
|
||
public IntStream intStream() { | ||
return IntStream.range(0, value); | ||
} | ||
Comment on lines
+29
to
+31
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. ํ์์๋ ์คํธ๋ฆผ์ ๋ฐํํ๋ ๋ก์ง์ ์์ฃผ ์ฌ์ฉํ์๋์? |
||
|
||
public LottoCount minus(LottoCount other) { | ||
validateMinus(other); | ||
return LottoCount.of(this.value - other.value); | ||
} | ||
Comment on lines
+33
to
+36
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. ๋ถ๋ณ ๊ฐ์ฒด ํ์ฉ ๐ |
||
|
||
private void validateMinus(LottoCount other) { | ||
if (this.value < other.value) { | ||
throw new LottoCountCannotBeNegativeException(); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "LottoCount{" + | ||
"count=" + value + | ||
'}'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.nextstep.camp.lotto.view.component; | ||
|
||
import com.nextstep.camp.common.strategy.InputStrategy; | ||
import com.nextstep.camp.common.view.component.AbstractInput; | ||
import com.nextstep.camp.lotto.domain.vo.LottoCount; | ||
|
||
public class LottoManuelCountInput extends AbstractInput<LottoCount> { | ||
|
||
private LottoManuelCountInput(InputStrategy<LottoCount> inputStrategy) { | ||
super(inputStrategy); | ||
} | ||
|
||
public static LottoManuelCountInput create(InputStrategy<LottoCount> inputStrategy) { | ||
return new LottoManuelCountInput(inputStrategy); | ||
} | ||
|
||
@Override | ||
public String getLabel() { | ||
return "\n์๋์ผ๋ก ๊ตฌ๋งคํ ๋ก๋ ์๋ฅผ ์ ๋ ฅํด ์ฃผ์ธ์."; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.nextstep.camp.lotto.view.component; | ||
|
||
import com.nextstep.camp.common.strategy.InputStrategy; | ||
import com.nextstep.camp.common.view.component.AbstractInput; | ||
import com.nextstep.camp.lotto.domain.entity.LottoTickets; | ||
import com.nextstep.camp.lotto.domain.vo.LottoCount; | ||
|
||
public class LottoTicketsAutoInput extends AbstractInput<LottoTickets> { | ||
|
||
private final LottoCount autoCount; | ||
private final LottoCount manualCount; | ||
|
||
private LottoTicketsAutoInput(InputStrategy<LottoTickets> inputStrategy, LottoCount autoCount, LottoCount manualCount) { | ||
super(inputStrategy); | ||
this.autoCount = autoCount; | ||
this.manualCount = manualCount; | ||
} | ||
|
||
public static LottoTicketsAutoInput create(InputStrategy<LottoTickets> inputStrategy, LottoCount autoCount, LottoCount manualCount) { | ||
return new LottoTicketsAutoInput(inputStrategy, autoCount, manualCount); | ||
} | ||
|
||
@Override | ||
public String getLabel() { | ||
return String.format("์๋์ผ๋ก %d์ฅ, ์๋์ผ๋ก %d๊ฐ๋ฅผ ๊ตฌ๋งคํ์ต๋๋ค.", manualCount.getCount(), autoCount.getCount()); | ||
} | ||
|
||
@Override | ||
public LottoTickets action() { | ||
LottoTickets lottoTickets = super.action(); | ||
System.out.println(lottoTickets); | ||
return lottoTickets; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.nextstep.camp.lotto.view.component; | ||
|
||
import com.nextstep.camp.common.strategy.InputStrategy; | ||
import com.nextstep.camp.common.view.component.AbstractInput; | ||
import com.nextstep.camp.lotto.domain.entity.LottoTickets; | ||
|
||
public class LottoTicketsManualInput extends AbstractInput<LottoTickets> { | ||
|
||
private LottoTicketsManualInput(InputStrategy<LottoTickets> inputStrategy) { | ||
super(inputStrategy); | ||
} | ||
|
||
public static LottoTicketsManualInput create(InputStrategy<LottoTickets> inputStrategy) { | ||
return new LottoTicketsManualInput(inputStrategy); | ||
} | ||
|
||
@Override | ||
public String getLabel() { | ||
return "\n์๋์ผ๋ก ๊ตฌ๋งคํ ๋ก๋ ๋ฒํธ๋ฅผ ์ ๋ ฅํด ์ฃผ์ธ์."; | ||
} | ||
} |
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.
์ ์์ ์ผ๋ก ๋์ํ๊ณ ์์ง ์๋ค์ ๐ข
