code-coverage-Emilia #24
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
13
src/test/java/Item/EquipmentTypeTest.java
Normal file
13
src/test/java/Item/EquipmentTypeTest.java
Normal 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 {
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user