public void getOperand(PerformFileOperations x)
        {
            switch (x.typeOfArithmetic)
            {
            case "add":
                operand = "+";
                break;

            case "subtract":
                operand = "-";
                break;

            case "multiply":
                operand = "*";
                break;

            case "divide":
                operand = "/";
                break;

            default:
                Console.Write("Unable to get operand");
                break;
            }
        }
Example #2
0
        public void work()
        {
            var x = new PerformFileOperations();
            var y = new PerformArithmetic();

            x.readFile();
            y.getOperand(x);
            y.getTotal(x);
            x.writeToFile();
        }
 public void getTotal(PerformFileOperations y)
 {
     if (y.typeOfArithmetic == "add")
     {
         total = y.firstOperand + y.secondOperand;
     }
     else if (y.typeOfArithmetic == "subtract")
     {
         total = y.firstOperand - y.secondOperand;
     }
     else if (y.typeOfArithmetic == "multiply")
     {
         total = y.firstOperand * y.secondOperand;
     }
     else if (y.typeOfArithmetic == "divide")
     {
         total = y.firstOperand / y.secondOperand;
     }
     else
     {
         Console.Write("Unable to calculate total");
     }
 }