diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-02-21 15:40:30 -0500 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-02-21 15:40:30 -0500 |
| commit | 77a797089a2e065cc8cf2a83ae8356b16591aebe (patch) | |
| tree | e88f80b126cbb6de08881beb0a8c97111966a2b7 /BJC-Utils2/src/main/java/bjc/utils/dice/CompoundDice.java | |
| parent | d8b3b3c5e4441cecec98c06a36fc81570008c888 (diff) | |
Revamping of the way dice work
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/dice/CompoundDice.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/dice/CompoundDice.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/dice/CompoundDice.java b/BJC-Utils2/src/main/java/bjc/utils/dice/CompoundDice.java new file mode 100644 index 0000000..ceb62aa --- /dev/null +++ b/BJC-Utils2/src/main/java/bjc/utils/dice/CompoundDice.java @@ -0,0 +1,43 @@ +package bjc.utils.dice; + +/** + * Implements a "compound dice" + * + * To explain, a compound dice is something like a d100 composed from two + * d10s instead of a hundred sided die. + * + * @author ben + * + */ +public class CompoundDice implements IDiceExpression { + /** + * The left die of the expression + */ + private IDiceExpression l; + /** + * The right die of the expression + */ + private IDiceExpression r; + + /** + * Create a new compound dice using the specified dice + * + * @param l + * The die to use on the left + * @param r + * The die to use on the right + */ + public CompoundDice(IDiceExpression l, IDiceExpression r) { + this.l = l; + this.r = r; + } + + @Override + public int roll() { + /* + * Make the combination of the two dice + */ + return Integer.parseInt(l.roll() + "" + r.roll()); + } + +} |
