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/FixedDiePool.java | 56 ---------------------- 1 file changed, 56 deletions(-) delete mode 100644 dice/src/main/java/bjc/dicelang/neodice/diepool/FixedDiePool.java (limited to 'dice/src/main/java/bjc/dicelang/neodice/diepool/FixedDiePool.java') diff --git a/dice/src/main/java/bjc/dicelang/neodice/diepool/FixedDiePool.java b/dice/src/main/java/bjc/dicelang/neodice/diepool/FixedDiePool.java deleted file mode 100644 index 4950407..0000000 --- a/dice/src/main/java/bjc/dicelang/neodice/diepool/FixedDiePool.java +++ /dev/null @@ -1,56 +0,0 @@ -package bjc.dicelang.neodice.diepool; - -import java.util.*; -import java.util.stream.*; - -import bjc.dicelang.neodice.*; - -public class FixedDiePool implements DiePool { - private final List> dice; - - public FixedDiePool(List> dice) { - this.dice = dice; - } - - @SafeVarargs - public FixedDiePool(Die...dice) { - this.dice = new ArrayList<>(dice.length); - for (Die die : dice) { - this.dice.add(die); - } - } - - @Override - public Stream roll(Random rng) { - return dice.stream().map((die) -> die.roll(rng)); - } - - @Override - public List> contained() { - return dice; - } - - - @Override - public String toString() { - return dice.stream() - .map(Die::toString) - .collect(Collectors.joining(", ")); - } - - @Override - public int hashCode() { - return Objects.hash(dice); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - - FixedDiePool other = (FixedDiePool) obj; - - return Objects.equals(dice, other.dice); - } -} \ No newline at end of file -- cgit v1.2.3