magic #3

Merged
erns6604 merged 2 commits from magic into main 2025-10-14 14:42:58 +02:00
2 changed files with 46 additions and 0 deletions

18
src/main/java/Spell.java Normal file
View 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;}
}

View 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");
}
}