01: package experiments;
02:
03: /**
04: * A class used for the testing of com.reeltwo.jumble. Includes an incorrect addition
05: * function (for coverage) and a multiply function (for timeouts)
06: *
07: * @author Tin Pavlinic
08: * @version $Revision: 496 $
09: */
10: public class JumblerExperiment {
11: /**
12: * Adds x and y
13: *
14: * @param x
15: * the first argument
16: * @param y
17: * the second argument
18: * @return the sum of x and y
19: */
20: public int add(int x, int y) {
21: if (x > y) {
22: return x + y;
23: }
24:
25: return x - y;
26: }
27:
28: /**
29: * Multiplies x and y
30: *
31: * @param x
32: * the first argument
33: * @param y
34: * the second argument
35: * @return the product of x and y
36: */
37: public int multiply(int x, int y) {
38: int total = 0;
39: int sum = 0;
40: int counter = 0;
41: while (counter < y) {
42: total++;
43: sum = sum + x;
44: counter++;
45: }
46:
47: return sum;
48: }
49: }
|