code-coverage-Emilia #24
@@ -2,17 +2,13 @@ package Item;
|
|||||||
|
|
||||||
public class BodyArmour extends EquipmentType{
|
public class BodyArmour extends EquipmentType{
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final AttributeModifier modifiers;
|
private final AttributeModifier modifiers;
|
||||||
|
|
||||||
public BodyArmour(String name, 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);
|
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() {
|
public AttributeModifier getModifiers() {
|
||||||
return modifiers;
|
return modifiers;
|
||||||
@@ -20,6 +16,6 @@ public class BodyArmour extends EquipmentType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name + modifiers;
|
return getName() + modifiers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,15 @@
|
|||||||
package Item;
|
package Item;
|
||||||
|
|
||||||
public abstract class EquipmentType {
|
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 String toString();
|
||||||
public abstract AttributeModifier getModifiers();
|
public abstract AttributeModifier getModifiers();
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,13 @@ package Item;
|
|||||||
|
|
||||||
public class MageHat extends EquipmentType{
|
public class MageHat extends EquipmentType{
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final AttributeModifier modifiers;
|
private final AttributeModifier modifiers;
|
||||||
|
|
||||||
public MageHat(String name, 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);
|
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() {
|
public AttributeModifier getModifiers() {
|
||||||
return modifiers;
|
return modifiers;
|
||||||
@@ -20,6 +16,6 @@ public class MageHat extends EquipmentType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name + modifiers;
|
return getName() + modifiers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
import Entity.Player;
|
import Entity.Player;
|
||||||
import Item.MageHat;
|
import Item.*;
|
||||||
import Job.Wizard;
|
import Job.Wizard;
|
||||||
import Job.Knight;
|
import Job.Knight;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import Item.Equipment;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import Item.BodyArmour;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import Item.AttributeModifier;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class EquipmentTest {
|
public class EquipmentTest {
|
||||||
@@ -142,6 +141,7 @@ public class EquipmentTest {
|
|||||||
assertFalse(e1.equals(e2));
|
assertFalse(e1.equals(e2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void canNotEquipWithWrongJob() {
|
void canNotEquipWithWrongJob() {
|
||||||
var p = defaultWizard();
|
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