static void Main(string[] args) { // new counter for program Counter thisCounterInst = new Counter(); // boolean for running program and breaking out of while loop bool isRunning = true; // while bool = true, run this loop while (isRunning) { // writing the counter Console.Write("[" + thisCounterInst.CountValue + "]"); // accepting the input string input = Console.ReadLine(); // validating that syntax is right and not exiting loop ValidInputs validating = new ValidInputs(); bool ValidateResult = validating.BreakingLoop(input); // if not valid result, exit loop if (ValidateResult == false) { isRunning = false; break; } else { // other wise, valid result -- new Calculator instance Calculator CalculatorInstance = new Calculator(); if (input == "lastq" || input == " lastq") { // show the last question Console.WriteLine(LastQnA.LastQ); } else if (input == "last" || input == " last") { // show last answer Console.WriteLine(LastQnA.LastAns); } else { // new calculator instance and begin calculation int thisAnswer = CalculatorInstance.Calculate(input); Console.WriteLine(thisAnswer); } // increment counter thisCounterInst.CountValue = thisCounterInst.Count + 1; } } }
public void UsingConstantSubtraction() { Constants.AddKey2Dictionary("e", 11); string input = "e - 2"; Calculator thisCalc = new Calculator(); string ConstSubtractionAns = thisCalc.Calculate(input); Assert.AreEqual("9", ConstSubtractionAns); }
public void UsingConstantMultiplication() { Constants.AddKey2Dictionary("d", 9); string input = "d * 2"; Calculator thisCalc = new Calculator(); string ConstMultiAns = thisCalc.Calculate(input); Assert.AreEqual("18", ConstMultiAns); }
public void UsingConstantModulus() { Constants.AddKey2Dictionary("b", 16); string input = "b % 2"; Calculator thisCalc = new Calculator(); string ConstModulusAns = thisCalc.Calculate(input); Assert.AreEqual("0", ConstModulusAns); }
public void UsingConstantDivision() { Constants.AddKey2Dictionary("c", 8); string input = "c / 2"; Calculator thisCalc = new Calculator(); string ConstDivisionAns = thisCalc.Calculate(input); Assert.AreEqual("4", ConstDivisionAns); }
public void UsingConstantAddition() { Constants.AddKey2Dictionary("a", 10); string input = "a + 2"; Calculator thisCalc = new Calculator(); string ConstAdditionAns = thisCalc.Calculate(input); Assert.AreEqual("12", ConstAdditionAns); }
public void TestingWithoutOp() { string input = "5"; Calculator thisCalc = new Calculator(); string AdditionAns = thisCalc.Calculate(input); }
public void TestingCalculatorSub() { string input = "12 - 2"; Calculator thisCalc = new Calculator(); string SubtractionAns = thisCalc.Calculate(input); Assert.AreEqual("10", SubtractionAns); }
public void TestingCalculatorMulti() { string input = "4 * 2"; Calculator thisCalc = new Calculator(); string MultiplicationAns = thisCalc.Calculate(input); Assert.AreEqual("8", MultiplicationAns); }
public void TestingCalculatorModulation() { string input = "11 % 2"; Calculator thisCalc = new Calculator(); string ModAns = thisCalc.Calculate(input); Assert.AreEqual("1", ModAns); }
public void TestingCalculatorDiv() { string input = "4 / 2"; Calculator thisCalc = new Calculator(); string DivisionAns = thisCalc.Calculate(input); Assert.AreEqual("2", DivisionAns); }
public void TestingCalculatorAddition() { string input = "4 + 2"; Calculator thisCalc = new Calculator(); string AdditionAns = thisCalc.Calculate(input); Assert.AreEqual("6", AdditionAns); }
public void test_substitute() { //arrange const string input = "//;\n1;2"; var delim = Substitute.For<IDelimiterExtractor>(); delim.GetDelimiters(input).Returns(new[] { ";" }); //act var res = new Calculator().Add(input); //assert res.Should().Be(3); }
private void BtMin_Click(object sender, EventArgs e) { Calculator Calculator = new Calculator(); tbUitkomst.Text = Convert.ToString(Calculator.Subtract(Convert.ToDouble(tbGetal1.Text), Convert.ToDouble(tbGetal2.Text))); }
private void Button2_Click(object sender, EventArgs e) { Calculator Calculator = new Calculator(); tbUitkomst.Text = Convert.ToString(Calculator.Square(Convert.ToDouble(tbGetal1.Text))); }