Harzminers
Implementing an extendable Calculator Console Application
I would like to create a console application that can parse algebraic terms with basic operators and values (int, decimal).
However, i am unsure regarding the correct approach to this.
My initial idea is to differentiate Values (implementing IValue interface) and Operators (IOperator interface) which are expected to alternate in a Term, starting and ending with an IValue (Brackets in a Term contain a Subterm/another Term, which would be considered a Value)
I could define classes for int, decimals etc named intValue etc., but i was hoping i could define a generic way of adding, subtracting etc. in my Operators (Addition, Subtraction etc.). However, the only interface that seems to allow these operations i found is INumber<T>, which would still require multiple methods for int/int , decimal/decimal etc. operations.
Any pointer regarding this problem, the general approach or good learning resources would be greatly appreciated.
1 replies