This commit is contained in:
nicoagostini committed 2025-09-21 00:42:25 -07:00
1 parent 9bb3af19a9
commit 18ec34592d
5 files changed
+6 -11

No files matched your search

@@ -107,7 +107,7 @@ public class Creature {
if (!this.isAlive()){
throw new RuntimeException("The creature is not alive.");
}
else{
if (damage < NO_HEALTH) {
throw new DamageException("Damage cannot be negative");
}
@@ -118,7 +118,6 @@ public class Creature {
this.health = NO_HEALTH;
}
}
}
/**
* heal increases the health value.
+1 -2
View File
@@ -83,11 +83,10 @@ public class Dragon extends Creature {
if (!this.isAlive()) {
throw new RuntimeException("The dragon is not alive.");
}
else {
if(firePower < FIRE_POWER_USAGE) {
throw new LowFirePowerException("Fire power too low");
}
}
this.firePower -= FIRE_POWER_USAGE;
+2 -2
View File
@@ -83,7 +83,7 @@ public class Elf extends Creature {
if(!this.isAlive()){
throw new RuntimeException("The elf is not alive.");
}
else{
if (this.mana < MANA_USAGE) {
throw new LowManaException("Not enough mana to cast spell");
}
@@ -91,7 +91,7 @@ public class Elf extends Creature {
this.mana -= MANA_USAGE;
target.takeDamage(MANA_DAMAGE);
}
}
/**
+1 -4
View File
@@ -86,7 +86,6 @@ public class Orc extends Creature {
if(!this.isAlive()){
throw new RuntimeException("The orc is not alive.");
}
else{
this.rage += RAGE_INCREMENT;
@@ -99,9 +98,7 @@ public class Orc extends Creature {
} else if (this.rage > DAMAGE_THRESHOLD) {
target.takeDamage(DAMAGE * DOUBLE);
} else {
target.takeDamage(DOUBLE);
}
target.takeDamage(DAMAGE);
}
}
+1 -1
View File
@@ -51,7 +51,7 @@ public class CreatureTest {
orc.printDetails();
if (orc instanceof Creature) System.out.println("This creature is an Orc.");
// Fight sequence — all guarded by friendly exception handling
try {
System.out.println("- Dragon breathed fire on the Elf");