Ejemplo n.º 1
0
        //It converts string expression into Operand object
        //It calculates power associated with the number like 2^2 will be converted into 4.
        private void ConvertToNaturalNumber(string operandToConvert)
        {
            bool isNegative = operandToConvert.ElementAt(0).Equals(Operator.MINUS);
            int  numberPart = OperandConverter.GetNumberPartFromNaturalNumber(operandToConvert, (isNegative) ? 1 : 0);
            int  powerPart  = OperandConverter.GetPowerFrom(operandToConvert);

            this.NaturalNumber = OperandConverter.GetPoweredNumber(numberPart, powerPart, isNegative);
        }
Ejemplo n.º 2
0
 //It converts string expression into Operand object of variable.
 //In the case of 2x^0, it will be treated as 1.
 private void ConvertToVariable(string operandToConvert)
 {
     this.NaturalNumber = OperandConverter.GetNaturalNumberFromVariable(operandToConvert);
     this.Power         = OperandConverter.GetPowerFrom(operandToConvert);
 }