Private
Public Access
Added better expressions
This commit is contained in:
1 parent
7035a3e06e
commit
7f16f31967
1 file changed
+30
+30
@@ -25,6 +25,36 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
||||
if (operation > 3 && operation < 0) throw new Exception("Bad operation");
|
||||
}
|
||||
|
||||
public ExpressionValue(Drawer drawer, IValue variable1, IValue variable2, string operation) {
|
||||
switch(operation) {
|
||||
case "+":
|
||||
this.operation = ADD;
|
||||
break;
|
||||
|
||||
case "-":
|
||||
this.operation = SUBTRACT;
|
||||
break;
|
||||
|
||||
case "*":
|
||||
this.operation = MULTIPLY;
|
||||
break;
|
||||
|
||||
case "/":
|
||||
this.operation = DIVIDE;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception("Undefined operation");
|
||||
}
|
||||
|
||||
this.variable1 = variable1;
|
||||
this.variable2 = variable2;
|
||||
|
||||
|
||||
//Check for bad input
|
||||
if (this.operation > 3 && this.operation < 0) throw new Exception("Bad operation");
|
||||
}
|
||||
|
||||
private IValue Evaluate() {
|
||||
if (evaluated) return evaluatedValue;
|
||||
|
||||
|
||||
Reference in new issue
Block a user