01: package org.hanseltest;
02:
03: /**
04: * Class containing all kinds of different uses of for-statements.
05: *
06: * @author Niklas Mehner
07: */
08: public class CoverFor {
09:
10: /**
11: * Contains a simple for-loop.
12: * @param n number of times the loop is executed.
13: * @return 5 + n
14: */
15: public int simpleFor(int n) {
16: int result = 5;
17: for (int i = 0; i < n; i++) {
18: result++;
19: }
20:
21: return result;
22: }
23:
24: /**
25: * Contains a loop with a little more complicated expression.
26: * @param n Possible number of times the loop is run.
27: * @param m Possible number of times the loop is run.
28: * @return 5 + min(n, m)
29: */
30: public int expressionFor(int n, int m) {
31: int result = 5;
32: for (int i = 0; (i < n) && (i < m); i++) {
33: result++;
34: }
35:
36: return result;
37: }
38:
39: }
|