예제 #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();
 }
예제 #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();
 }
예제 #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());
        }
예제 #4
0
        public double SquareRt(double a)
        {
            return(SquareRoot.SqrRoot(a));

            //return result;
        }