inventory #14
@@ -2,7 +2,6 @@ package Shared;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class LootTable<T> {
|
||||
private RandomProvider random;
|
||||
@@ -18,6 +17,8 @@ public class LootTable<T> {
|
||||
this.entries.addAll(entries);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setRandomProvider(RandomProvider random) {
|
||||
this.random = random;
|
||||
}
|
||||
@@ -43,4 +44,7 @@ public class LootTable<T> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<LootEntry<T>> getEntries() {
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,8 @@ import Shared.LootTable;
|
||||
import Shared.RandomProvider;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.anyOf;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -19,6 +17,12 @@ public class LootTableTest {
|
||||
return lootTable;
|
||||
}
|
||||
|
||||
@Test
|
||||
void instantiates_as_empty() {
|
||||
LootTable<String> lootTable = new LootTable<>();
|
||||
assertThat(lootTable.getEntries().size(), is(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void returns_an_item_was_added() {
|
||||
LootTable<String> loot = defaultLootTable();
|
||||
@@ -33,7 +37,11 @@ public class LootTableTest {
|
||||
LootTable<String> loot = new LootTable<>(mockRandomProvider);
|
||||
loot.addEntry("Stone", 90);
|
||||
loot.addEntry("Iron", 10);
|
||||
|
||||
String result = loot.roll();
|
||||
assertThat(result, equalTo("Iron"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user