Line | |
---|
1 | package omq.test.python; |
---|
2 | |
---|
3 | import omq.server.RemoteObject; |
---|
4 | |
---|
5 | /** |
---|
6 | * |
---|
7 | * @author Sergi Toda <sergi.toda@estudiants.urv.cat> |
---|
8 | * |
---|
9 | */ |
---|
10 | public class CalculatorImpl extends RemoteObject implements Calculator { |
---|
11 | |
---|
12 | /** |
---|
13 | * |
---|
14 | */ |
---|
15 | private static final long serialVersionUID = 1L; |
---|
16 | |
---|
17 | @Override |
---|
18 | public void fibonacci(int x) { |
---|
19 | System.out.println(fib(x)); |
---|
20 | } |
---|
21 | |
---|
22 | public int fib(int x) { |
---|
23 | if (x == 0) { |
---|
24 | return 0; |
---|
25 | } |
---|
26 | if (x == 1) { |
---|
27 | return 1; |
---|
28 | } |
---|
29 | return fib(x - 1) + fib(x - 2); |
---|
30 | } |
---|
31 | |
---|
32 | public int add(int x, int y) { |
---|
33 | System.out.println("add: " + x + "+" + y + "=" + (x + y)); |
---|
34 | return x + y; |
---|
35 | } |
---|
36 | |
---|
37 | @Override |
---|
38 | public double getPi() { |
---|
39 | return 3.1415; |
---|
40 | } |
---|
41 | |
---|
42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.