Ejemplo n.º 1
0
        public bool execute()
        {
            //Postcondition: Returns the boolean result of [arith1] [op] [arith2] (i.e. 1 < 2)
            switch (op)
            {
            case BoolOperator.EQL_OP:
                return(arith1.evaluate() == arith2.evaluate());

            case BoolOperator.GREQ_OP:
                return(arith1.evaluate() >= arith2.evaluate());

            case BoolOperator.GRTN_OP:
                return(arith1.evaluate() > arith2.evaluate());

            case BoolOperator.LSQU_OP:
                return(arith1.evaluate() <= arith2.evaluate());

            case BoolOperator.LSTN_OP:
                return(arith1.evaluate() < arith2.evaluate());

            case BoolOperator.NTEQL_OP:
                return(arith1.evaluate() != arith2.evaluate());

            default:
                throw new Exception("Invalid BoolOperator used in BoolExpression evaluation");
            }
        }
Ejemplo n.º 2
0
 public void execute()
 {
     //Postcondition: Prints the ArithExpression's value to the console
     Console.WriteLine($"{arith.evaluate()}");
 }
Ejemplo n.º 3
0
 public void execute()
 {
     //Postcondition: Makes the Id's current value equal to the ArithExpression's value
     Memory.store(id.Character, arith.evaluate());
 }