diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-21 14:08:50 -0400 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2017-03-21 14:08:50 -0400 |
| commit | a7e84eea087a35721a971e827149f0ca5fba4676 (patch) | |
| tree | fbb7b0e5e402fb2a4aae5614c51f1955640a09e8 /dice-lang/src/bjc/dicelang/v1/OperatorDiceExpression.java | |
| parent | 94913a2fccff9e80f84ac477c2020bd7c7b1833a (diff) | |
Remove version 1 files
Remove the old, not used version 1 files from the repository. Check the
history if you care about them.
Diffstat (limited to 'dice-lang/src/bjc/dicelang/v1/OperatorDiceExpression.java')
| -rw-r--r-- | dice-lang/src/bjc/dicelang/v1/OperatorDiceExpression.java | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/dice-lang/src/bjc/dicelang/v1/OperatorDiceExpression.java b/dice-lang/src/bjc/dicelang/v1/OperatorDiceExpression.java deleted file mode 100644 index a5d37e2..0000000 --- a/dice-lang/src/bjc/dicelang/v1/OperatorDiceExpression.java +++ /dev/null @@ -1,80 +0,0 @@ -package bjc.dicelang.v1; - -/** - * Implements a class for combining two dice with an operator - * - * @author ben - * - */ -public class OperatorDiceExpression implements IDiceExpression { - /* - * The operator to use for combining the dice - */ - private DiceExpressionType type; - - /* - * The dice on the left side of the expression - */ - private IDiceExpression left; - - /* - * The dice on the right side of the expression - */ - private IDiceExpression right; - - /** - * Create a new compound expression using the specified parameters - * - * @param rght - * The die on the right side of the expression - * @param lft - * The die on the left side of the expression - * @param type - * The operator to use for combining the dices - */ - public OperatorDiceExpression(IDiceExpression rght, IDiceExpression lft, DiceExpressionType type) { - this.right = rght; - this.left = lft; - this.type = type; - } - - @Override - public int roll() { - /* - * Handle each operator - */ - switch(type) { - case ADD: - return right.roll() + left.roll(); - case SUBTRACT: - return right.roll() - left.roll(); - case MULTIPLY: - return right.roll() * left.roll(); - case DIVIDE: - /* - * Round to keep results as integers. We don't really - * have any need for floating-point dice, and continuous - * probability is a pain - */ - try { - return right.roll() / left.roll(); - } catch(ArithmeticException aex) { - UnsupportedOperationException usex = new UnsupportedOperationException( - "Attempted to divide by zero." + " Problematic expression is " + left); - - usex.initCause(aex); - - throw usex; - } - default: - throw new IllegalArgumentException( - "Got passed a invalid ScalarExpressionType (" + type + "). WAT"); - - } - } - - @Override - public String toString() { - return "dice-exp[type=" + type + ", l=" + left.toString() + ", r=" + right.toString() + "]"; - } -} |
