KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmock > examples > calculator > SimpleExpressionFactory


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

3 package org.jmock.examples.calculator;
4
5 import org.jmock.examples.calculator.expression.*;
6
7
8 public class SimpleExpressionFactory implements ExpressionFactory
9 {
10     public Expression newLiteral( double value ) {
11         return new Literal(value);
12     }
13
14     public Expression newAddition( Expression left, Expression right ) {
15         return new Addition(left, right);
16     }
17
18     public Expression newSubtraction( Expression left, Expression right ) {
19         return new Subtraction(left, right);
20     }
21
22     public Expression newMultiplication( Expression left, Expression right ) {
23         return new Multiplication(left, right);
24     }
25
26     public Expression newDivision( Expression left, Expression right ) {
27         return new Division(left, right);
28     }
29
30     public Expression newPower( Expression left, Expression right ) {
31         return new Power(left, right);
32     }
33
34     public Expression newVariableReference( String JavaDoc variableName ) {
35         return new VariableReference(variableName);
36     }
37 }
38
Popular Tags