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