Job terrain #12

Merged
erns6604 merged 16 commits from job_terrain into main 2025-10-28 11:21:35 +01:00
2 changed files with 6 additions and 3 deletions
Showing only changes of commit d7cfa47277 - Show all commits

View File

@ -1,6 +1,7 @@
package Inventory; package Inventory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
public class Inventory { public class Inventory {
@ -10,8 +11,8 @@ public class Inventory {
items = new ArrayList<>(); items = new ArrayList<>();
} }
List<String> getItems() { public List<String> getItems() {
return items; return Collections.unmodifiableList(items);
} }
public void addItem(String item) { public void addItem(String item) {

View File

@ -7,6 +7,8 @@ import Entity.Player;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import Job.Wizard; import Job.Wizard;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
class PlayerTest { class PlayerTest {
@ -55,7 +57,7 @@ class PlayerTest {
var p = new Player("John"); var p = new Player("John");
p.learnJob(new Miner()); p.learnJob(new Miner());
p.performAction(new DigAction()); p.performAction(new DigAction());
assertTrue(p.getInventory().containsItem("Stone")); assertThat(p.getInventory().getItems(), hasItem("Stone"));
} }
@Test @Test