public
class Calculator
{
static
private Dictionary<OPERATOR, Func<
int,
int,
int>> calculationAction =
new Dictionary<OPERATOR, Func<
int,
int,
int>> {
{ OPERATOR.Add, Add },
{ OPERATOR.Minus, Minus },
{ OPERATOR.Multiply, Multiply },
{ OPERATOR.Divide, Divide }
};
public
static OPERATOR GetOperator2(
char ch)
{
if (OperatorMap.ContainsKey(ch))
return OperatorMap[ch];
else
return OPERATOR.Unknown;
}
static
int Add(
int number1,
int number2)
{
return number1 + number2;
}
// Others are omitted here for brevity
}