Added: BuildingCard check on price

This commit is contained in:
2026-03-19 17:58:48 +01:00
parent c94e96e135
commit 677a12a833
2 changed files with 28 additions and 7 deletions
@@ -23,15 +23,23 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
return effectType; return effectType;
} }
public BuildingCard(int era,int price) { public BuildingCard(int era,int price) throws IllegalArgumentException{
super(era); super(era);
if (price > 0) {
this.price = price; this.price = price;
} else {
throw new IllegalArgumentException();
} }
public BuildingCard(int effectId,EffectType effectType ,int era,int price) { }
public BuildingCard(int effectId,EffectType effectType ,int era,int price) throws IllegalArgumentException{
this.effectId = effectId; this.effectId = effectId;
this.effectType = effectType; this.effectType = effectType;
super(era); super(era);
if (price > 0) {
this.price = price; this.price = price;
} else {
throw new IllegalArgumentException();
}
} }
@@ -12,9 +12,22 @@ class Building13Test {
void testClone() { void testClone() {
assertThrows(IllegalArgumentException.class, () -> { assertThrows(IllegalArgumentException.class, () -> {
Building13 b2 = new Building13(0, 15); Building13 b2 = new Building13(0, 15);
Building13 b3 = new Building13(-1, 100); });
Building13 b4 = new Building13(5, -10);
Building13 b5 = new Building13(-2, 0); assertThrows(IllegalArgumentException.class, () -> {
Building13 b3 = new Building13(-1, 15);
});
assertThrows(IllegalArgumentException.class, () -> {
Building13 b4 = new Building13(4, 15);
});
assertThrows(IllegalArgumentException.class, () -> {
Building13 b5 = new Building13(2, 0);
});
assertThrows(IllegalArgumentException.class, () -> {
Building13 b6 = new Building13(1, -15);
}); });
Building13 b1 = new Building13(1, 10); Building13 b1 = new Building13(1, 10);