StandardCalculator.LastResult - YiZhang-Paul/Mock_Up_Calculator GitHub Wiki

Namespace: CalculatorClassLibrary

Description: Gets most recent calculation result.

Returns Description
decimal most recent calculation result

Remarks:

The calculator attempts to evaluate the expression every time a new input is received, and result from successful evaluation will be saved and will overwrite previous result.

For example, When current expression is "1 + 3", the "LastResult" property will be 4 since expression is valid; when a minus sign is received, the expression becomes "1 + 3 -" and the "LastResult" remains the same, as the expression is not valid yet; when an operand is received, such as 5, the expression then becomes "1 + 3 - 5" which is a valid expression. The calculator will then attempt to evaluate the expression again and the value of "LastResult" will become -1.