1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.examples.impl; |
16 |
| |
17 |
| import org.apache.examples.Adder; |
18 |
| import org.apache.examples.Calculator; |
19 |
| import org.apache.examples.Divider; |
20 |
| import org.apache.examples.Multiplier; |
21 |
| import org.apache.examples.Subtracter; |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| public class CalculatorImpl implements Calculator |
31 |
| { |
32 |
| private Adder _adder; |
33 |
| private Subtracter _subtracter; |
34 |
| private Multiplier _multiplier; |
35 |
| private Divider _divider; |
36 |
| |
37 |
0
| public double add(double arg0, double arg1)
|
38 |
| { |
39 |
0
| return _adder.add(arg0, arg1);
|
40 |
| } |
41 |
| |
42 |
0
| public double subtract(double arg0, double arg1)
|
43 |
| { |
44 |
0
| return _subtracter.subtract(arg0, arg1);
|
45 |
| } |
46 |
| |
47 |
0
| public double multiply(double arg0, double arg1)
|
48 |
| { |
49 |
0
| return _multiplier.multiply(arg0, arg1);
|
50 |
| } |
51 |
| |
52 |
0
| public double divide(double arg0, double arg1)
|
53 |
| { |
54 |
0
| return _divider.divide(arg0, arg1);
|
55 |
| } |
56 |
| |
57 |
0
| public void setAdder(Adder adder)
|
58 |
| { |
59 |
0
| _adder = adder;
|
60 |
| } |
61 |
| |
62 |
0
| public void setDivider(Divider divider)
|
63 |
| { |
64 |
0
| _divider = divider;
|
65 |
| } |
66 |
| |
67 |
0
| public void setMultiplier(Multiplier multiplier)
|
68 |
| { |
69 |
0
| _multiplier = multiplier;
|
70 |
| } |
71 |
| |
72 |
0
| public void setSubtracter(Subtracter subtracter)
|
73 |
| { |
74 |
0
| _subtracter = subtracter;
|
75 |
| } |
76 |
| |
77 |
| } |