using System; namespace ALGA { public class Operand : Expression { private char operand; private Expression left, right; public Operand(char operand, Expression left, Expression right) { this.operand = operand; this.left = left; this.right = right; } public override int evaluate() { int a = left.evaluate(); int b = right.evaluate(); switch (operand) { case '+': return a + b; case '*': return a * b; } throw new NotImplementedException(); } public override string ToString() { return $"({left.ToString()}{operand}{right.ToString()})"; } } }