KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmock > examples > calculator > expression > Division


1 /* Copyright (c) 2000-2004 jMock.org
2  */

3 package org.jmock.examples.calculator.expression;
4
5 import org.jmock.examples.calculator.CalculatorException;
6 import org.jmock.examples.calculator.Expression;
7
8
9 public class Division extends BinaryOperator
10 {
11
12     public Division( Expression left, Expression right ) {
13         super(left, right);
14     }
15
16     protected double operator( double left, double right )
17             throws CalculatorException {
18         if (right == 0.0) {
19             throw new CalculatorException("divide by zero");
20         }
21         return left / right;
22     }
23 }
Popular Tags