diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-02-05 07:02:45 -0500 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-02-05 07:02:45 -0500 |
| commit | 186b9131d46d886c98316e5b582e0cdd734a5024 (patch) | |
| tree | 5a81a9163817f1b4cd9948a57dc9569d975bc38f /dice-lang/src/bjc/dicelang/OperatorDiceExpression.java | |
| parent | e7a7cf10e2e9e05a6b12fd7c4d8d0ff2146901d9 (diff) | |
Cleanup
Diffstat (limited to 'dice-lang/src/bjc/dicelang/OperatorDiceExpression.java')
| -rw-r--r-- | dice-lang/src/bjc/dicelang/OperatorDiceExpression.java | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/dice-lang/src/bjc/dicelang/OperatorDiceExpression.java b/dice-lang/src/bjc/dicelang/OperatorDiceExpression.java index f86773d..63bf548 100644 --- a/dice-lang/src/bjc/dicelang/OperatorDiceExpression.java +++ b/dice-lang/src/bjc/dicelang/OperatorDiceExpression.java @@ -7,55 +7,50 @@ package bjc.dicelang; * */ public class OperatorDiceExpression implements IDiceExpression { - /** + /* * The operator to use for combining the dice */ - private DiceExpressionType expressionType; + private DiceExpressionType type; - /** + /* * The dice on the left side of the expression */ - private IDiceExpression leftExpression; + private IDiceExpression left; - /** + /* * The dice on the right side of the expression */ - private IDiceExpression rightExpression; + private IDiceExpression right; /** * Create a new compound expression using the specified parameters * - * @param right + * @param rght * The die on the right side of the expression - * @param left + * @param lft * The die on the left side of the expression * @param type * The operator to use for combining the dices */ - public OperatorDiceExpression(IDiceExpression right, - IDiceExpression left, DiceExpressionType type) { - this.rightExpression = right; - this.leftExpression = left; - this.expressionType = type; + public OperatorDiceExpression(IDiceExpression rght, + IDiceExpression lft, DiceExpressionType type) { + this.right = rght; + this.left = lft; + this.type = type; } - /* - * (non-Javadoc) - * - * @see bjc.utils.dice.IDiceExpression#roll() - */ @Override public int roll() { /* * Handle each operator */ - switch (expressionType) { + switch (type) { case ADD: - return rightExpression.roll() + leftExpression.roll(); + return right.roll() + left.roll(); case SUBTRACT: - return rightExpression.roll() - leftExpression.roll(); + return right.roll() - left.roll(); case MULTIPLY: - return rightExpression.roll() * leftExpression.roll(); + return right.roll() * left.roll(); case DIVIDE: /* * Round to keep results as integers. We don't really have @@ -63,12 +58,12 @@ public class OperatorDiceExpression implements IDiceExpression { * probability is a pain */ try { - return rightExpression.roll() / leftExpression.roll(); + return right.roll() / left.roll(); } catch (ArithmeticException aex) { UnsupportedOperationException usex = new UnsupportedOperationException( "Attempted to divide by zero." + " Problematic expression is " - + leftExpression); + + left); usex.initCause(aex); @@ -76,21 +71,16 @@ public class OperatorDiceExpression implements IDiceExpression { } default: throw new IllegalArgumentException( - "Got passed a invalid ScalarExpressionType (" - + expressionType + "). WAT"); + "Got passed a invalid ScalarExpressionType (" + + type + "). WAT"); } } - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ @Override public String toString() { - return "dice-exp[type=" + expressionType + ", l=" - + leftExpression.toString() + ", r=" - + rightExpression.toString() + "]"; + return "dice-exp[type=" + type + ", l=" + + left.toString() + ", r=" + + right.toString() + "]"; } -}
\ No newline at end of file +} |
