Ejemplo n.º 1
0
 public CalculatorBody()
 {
     this.sum        = new Addition();
     this.difference = new Subtraction();
     this.product    = new Multiplication();
     this.quotient   = new Division();
     this.exponent   = new Exponentiation();
     this.sqrt       = new SquareRoot();
     this.input      = new UserInputOutput();
 }
Ejemplo n.º 2
0
 public CalculatorBody()
 {
     this.sum = new Addition();
     this.difference = new Subtraction();
     this.product = new Multiplication();
     this.quotient = new Division();
     this.exponent = new Exponentiation();
     this.sqrt = new SquareRoot();
     this.input = new UserInputOutput();
 }
Ejemplo n.º 3
0
        // Menghitung hasil operasi <operand1> <operator> <operand2>
        public double calculate()
        {
            Expression temp = new TerminalExpression(0);

            switch (operatorSign)
            {
            case "+":
                temp = new Addition(operand1, operand2);
                break;

            case "-":
                temp = new Substraction(operand1, operand2);
                break;

            case "*":
                temp = new Multiplication(operand1, operand2);
                break;

            case "/":
                temp = new Division(operand1, operand2);
                break;

            case "^":
                temp = new Power(operand1, operand2);
                break;

            case "sqrt":
                temp = new SquareRoot(operand1);
                break;

            case "mod":
                temp = new Modulus(operand1, operand2);
                break;
            }
            return(temp.solve());
        }
Ejemplo n.º 4
0
        public double SquareRt(double a)
        {
            return(SquareRoot.SqrRoot(a));

            //return result;
        }