code-coverage-Emilia #24

Merged
erns6604 merged 14 commits from code-coverage-Emilia into main 2025-10-31 16:29:43 +01:00
5 changed files with 30 additions and 19 deletions
Showing only changes of commit f5e2f0d0cb - Show all commits

View File

@@ -2,17 +2,13 @@ package Item;
public class BodyArmour extends EquipmentType{
private final String name;
private final AttributeModifier modifiers;
public BodyArmour(String name, AttributeModifier modifiers) {
this.name = name;
super(name);
this.modifiers = new AttributeModifier(modifiers.getMaxHpMod(), modifiers.getMaxMpMod(), modifiers.getStrMod(), modifiers.getMagicStrMod(), modifiers.getDefMod()*2, modifiers.getMagicDefMod()*2);
}
public String getName() {
return name;
}
public AttributeModifier getModifiers() {
return modifiers;
@@ -20,6 +16,6 @@ public class BodyArmour extends EquipmentType{
@Override
public String toString() {
return name + modifiers;
return getName() + modifiers;
}
}

View File

@@ -1,9 +1,15 @@
package Item;
public abstract class EquipmentType {
public String name;
private String name;
public abstract String getName();
public EquipmentType(String name) {
this.name = name;
}
public String getName() {
return name;
};
public abstract String toString();
public abstract AttributeModifier getModifiers();

View File

@@ -2,17 +2,13 @@ package Item;
public class MageHat extends EquipmentType{
private final String name;
private final AttributeModifier modifiers;
public MageHat(String name, AttributeModifier modifiers) {
this.name = name;
super(name);
this.modifiers = new AttributeModifier(modifiers.getMaxHpMod(), modifiers.getMaxMpMod(), modifiers.getStrMod(), modifiers.getMagicStrMod()*2, modifiers.getDefMod(), modifiers.getMagicDefMod()*2);
}
public String getName() {
return name;
}
public AttributeModifier getModifiers() {
return modifiers;
@@ -20,6 +16,6 @@ public class MageHat extends EquipmentType{
@Override
public String toString() {
return name + modifiers;
return getName() + modifiers;
}
}

View File

@@ -1,13 +1,12 @@
import Entity.Player;
import Item.MageHat;
import Item.*;
import Job.Wizard;
import Job.Knight;
import org.junit.jupiter.api.Test;
import Item.Equipment;
import Item.BodyArmour;
import Item.AttributeModifier;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.jupiter.api.Assertions.*;
public class EquipmentTest {
@@ -142,6 +141,7 @@ public class EquipmentTest {
assertFalse(e1.equals(e2));
}
@Test
void canNotEquipWithWrongJob() {
var p = defaultWizard();

View File

@@ -0,0 +1,13 @@
package Item;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.jupiter.api.Assertions.*;
class EquipmentTypeTest {
}