Added: BuildingCard check on price
This commit is contained in:
@@ -23,15 +23,23 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
|
||||
return effectType;
|
||||
}
|
||||
|
||||
public BuildingCard(int era,int price) {
|
||||
public BuildingCard(int era,int price) throws IllegalArgumentException{
|
||||
super(era);
|
||||
this.price = price;
|
||||
if (price > 0) {
|
||||
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.effectType = effectType;
|
||||
super(era);
|
||||
this.price = price;
|
||||
if (price > 0) {
|
||||
this.price = price;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+16
-3
@@ -12,9 +12,22 @@ class Building13Test {
|
||||
void testClone() {
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user