public double Plus(double summand) { CurrentResult += summand; _latestOperation = CalculatorOperations.Plus; _latestParameter = summand; return(CurrentResult); }
public double Minus(double subtrahend) { CurrentResult -= subtrahend; _latestOperation = CalculatorOperations.Minus; _latestParameter = subtrahend; return(CurrentResult); }
public double Multiply(double multiplier) { CurrentResult *= multiplier; _latestOperation = CalculatorOperations.Multiply; _latestParameter = multiplier; return(CurrentResult); }
public void WrittenValueTestModulus() { //Set values to test string testNumber1 = "one"; string testNumber2 = "two"; string result = CalculatorOperations.CalculateAnswer("Modulus", testNumber1, testNumber2); }
public void Divide(int num1, int num2, int expected) { var arraySolver = new CalculatorOperations(); int actual = arraySolver.DivideThis(num1, num2); Assert.Equal(expected, actual); }
public void Multiply(int[] numbers, int expected) { var arraySolver = new CalculatorOperations(); int actual = arraySolver.MultiplyThis(numbers); Assert.Equal(expected, actual); }
public void AdditionTest() { //Set values to test string testNumber1 = "10"; string testNumber2 = "4"; string actualResult = CalculatorOperations.CalculateAnswer("Add", testNumber1, testNumber2); string expectedResult = "14"; Assert.AreEqual(actualResult, expectedResult); }
public void MultiplyTest() //requirement 2.1 / 2.2 { //Set values to test string testNumber1 = "10"; string testNumber2 = "4"; string actualResult = CalculatorOperations.CalculateAnswer("Multiply", testNumber1, testNumber2); string expectedResult = "40"; Assert.AreEqual(actualResult, expectedResult); }
public double Divide(double divisor) { if (divisor == 0) { throw new ArgumentException("Divisor cannot be 0!"); } CurrentResult /= divisor; _latestOperation = CalculatorOperations.Divide; _latestParameter = divisor; return(CurrentResult); }
public int Execute(CalculatorOperations operation, CalculatorArguments args) { switch (operation) { case CalculatorOperations.Add: return Add(args); case CalculatorOperations.Sub: return Sub(args); case CalculatorOperations.Mul: return Mul(args); case CalculatorOperations.Div: return Div(args); default: throw new InvalidOperationException(); } }
public void ProcessBinOp(CalculatorOperations op) { if (this.op.HasValue && input.HasValue && result.HasValue) { Compute(); this.op = op; } else { this.op = op; } if (input.HasValue) { result = input; Clear(); } }
private void xor_btn_Click(object sender, EventArgs e) { operation_label.Text = "^"; operation = CalculatorOperations.XOR; }
private void and_btn_Click(object sender, EventArgs e) { operation_label.Text = "*"; operation = CalculatorOperations.AND; }
private void btnMultiply_Click(object sender, EventArgs e) { txtAnswer.Text = CalculatorOperations.CalculateAnswer("Multiply", txtNumber1.Text, txtNumber2.Text); }
private void btnSubtract_Click(object sender, EventArgs e) { txtAnswer.Text = CalculatorOperations.CalculateAnswer("Subtract", txtNumber1.Text, txtNumber2.Text); }
private void btnDivide_Click(object sender, EventArgs e) { txtAnswer.Text = CalculatorOperations.CalculateAnswer("Divide", txtNumber1.Text, txtNumber2.Text); }
public StandardCalculator() { _latestOperation = CalculatorOperations.None; }
public void Clear() { _latestOperation = CalculatorOperations.Clear; CurrentResult = 0; _latestParameter = 0; }
public double Cube() { _latestOperation = CalculatorOperations.Cube; return(CurrentResult * CurrentResult * CurrentResult); }
public double Square() { _latestOperation = CalculatorOperations.Square; return(CurrentResult * CurrentResult); }