magic #3
18
src/main/java/Spell.java
Normal file
18
src/main/java/Spell.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
public class Spell {
|
||||||
|
private final String spellName;
|
||||||
|
private int cost;
|
||||||
|
private int potency;
|
||||||
|
|
||||||
|
public Spell(String spellName, int cost, int potency) {
|
||||||
|
this.spellName = spellName;
|
||||||
|
this.cost = cost;
|
||||||
|
this.potency = potency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSpellName() {return spellName;}
|
||||||
|
|
||||||
|
public int getCost() {return cost;}
|
||||||
|
|
||||||
|
public int getPotency() {return potency;}
|
||||||
|
}
|
||||||
|
|
||||||
28
src/test/java/SpellTest.java
Normal file
28
src/test/java/SpellTest.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
public class SpellTest {
|
||||||
|
|
||||||
|
private Spell defaultSpell() {
|
||||||
|
return new Spell("fireball", 20, 40);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setSpellNameOnCreation(){
|
||||||
|
var spell = defaultSpell();
|
||||||
|
assertEquals("fireball", spell.getSpellName(), "Spell name should be set");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setCostOnCreation() {
|
||||||
|
var spell = defaultSpell();
|
||||||
|
assertEquals(20, spell.getCost(), "Spell cost should have been set");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void setPotencyOnCreation() {
|
||||||
|
var spell = defaultSpell();
|
||||||
|
assertEquals(40, spell.getPotency(), "spell potency should have been set");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user