KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > examples > calcserver > Calculator


1 package com.mockobjects.examples.calcserver;
2
3 public class Calculator implements IntCalculator {
4
5     /**
6      * Calculator constructor comment.
7      */

8     public Calculator() {
9         super();
10     }
11
12
13     public int calculate(int value1, int value2, String JavaDoc operation) throws CalculatorException {
14         if ("/add".equalsIgnoreCase(operation)) {
15             return value1 + value2;
16         } else if ("/subtract".equalsIgnoreCase(operation)) {
17             return value1 - value2;
18         } else {
19             throw new CalculatorException("Bad operation: " + operation);
20         }
21     }
22 }
Popular Tags