magic #3

Merged
erns6604 merged 2 commits from magic into main 2025-10-14 14:42:58 +02:00
3 changed files with 47 additions and 1 deletions
Showing only changes of commit 860dc72590 - Show all commits

2
.idea/misc.xml generated
View File

@@ -8,7 +8,7 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="23" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_24" default="true" project-jdk-name="24" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

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