Ça trolle…
/
troll.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Isotropic sayings' relative frequency shouldn't be thrice the others'.
[troll.git]
/
src
/
main
/
java
/
com
/
codingame
/
game
/
Model.java
diff --git
a/src/main/java/com/codingame/game/Model.java
b/src/main/java/com/codingame/game/Model.java
index
e8cdc57
..
405db66
100644
(file)
--- a/
src/main/java/com/codingame/game/Model.java
+++ b/
src/main/java/com/codingame/game/Model.java
@@
-25,16
+25,37
@@
class Model {
private int multiplier;
public int getMultiplier() { return multiplier; }
private int multiplier;
public int getMultiplier() { return multiplier; }
- public void setMultiplier(int m){ multiplier = m; }
+ public void setMultiplier(int m) { multiplier = m; }
+
+ class FailedToThrowStonesAndShouldHave extends Exception {}
+ class ThrewMoreStonesThanHad extends Exception {}
private int stones;
public int getStones() { return stones; }
private int stones;
public int getStones() { return stones; }
- public void consumeStones(int n) throws InvalidAction {
+ public void consumeStones(int n)
+ throws ThrewMoreStonesThanHad,
+ FailedToThrowStonesAndShouldHave
+ {
if (n > stones) {
if (n > stones) {
- throw new InvalidAction("attempted to throw more stones than they had.");
+ throw new ThrewMoreStonesThanHad();
+ }
+ if (n == 0 && stones > 0) {
+ throw new FailedToThrowStonesAndShouldHave();
}
setStones(stones - n);
}
}
setStones(stones - n);
}
+ public int consumeMaxStones() {
+ int r = stones;
+ stones = 0;
+ return r;
+ }
+ public int consumeMinStones() {
+ if (stones < 1) {
+ throw new Error("Internal error: tried to consume min stones on an empty heap.");
+ }
+ stones--;
+ return 1;
+ }
public void setStones(int n) {
stones = n;
}
public void setStones(int n) {
stones = n;
}