From 7efb7b9e997e0977c8343718cd8b5149805ea57b Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Sat, 13 Mar 2021 09:11:12 -0500 Subject: Add more documentation Also, changed my mind on the way DiePool and its implementations should be structured. The implementations go in the die pool file as internal classes, because nobody should particularly care the specifics about their die pool, only that it does what it says it should --- .../bjc/dicelang/neodice/diepool/TimesDiePool.java | 54 ---------------------- 1 file changed, 54 deletions(-) delete mode 100644 dice/src/main/java/bjc/dicelang/neodice/diepool/TimesDiePool.java (limited to 'dice/src/main/java/bjc/dicelang/neodice/diepool/TimesDiePool.java') diff --git a/dice/src/main/java/bjc/dicelang/neodice/diepool/TimesDiePool.java b/dice/src/main/java/bjc/dicelang/neodice/diepool/TimesDiePool.java deleted file mode 100644 index e039e47..0000000 --- a/dice/src/main/java/bjc/dicelang/neodice/diepool/TimesDiePool.java +++ /dev/null @@ -1,54 +0,0 @@ -package bjc.dicelang.neodice.diepool; - -import java.util.*; -import java.util.stream.*; - -import bjc.dicelang.neodice.*; - -public class TimesDiePool implements DiePool { - private final Die contained; - private final int numDice; - - public TimesDiePool(Die contained, int numDice) { - this.contained = contained; - this.numDice = numDice; - } - - @Override - public Stream roll(Random rng) { - return Stream.generate(() -> contained.roll(rng)) - .limit(numDice); - } - - @Override - public List> contained() { - List> results = new ArrayList<>(numDice); - - for (int index = 0; index < numDice; index++) { - results.add(contained); - } - - return results; - } - - @Override - public String toString() { - return String.format("%d%s", numDice, contained); - } - - @Override - public int hashCode() { - return Objects.hash(contained, numDice); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - - TimesDiePool other = (TimesDiePool) obj; - - return Objects.equals(contained, other.contained) && numDice == other.numDice; - } -} \ No newline at end of file -- cgit v1.2.3