-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounter1ConstructorStaticTester.java
More file actions
32 lines (29 loc) · 1.21 KB
/
Copy pathCounter1ConstructorStaticTester.java
File metadata and controls
32 lines (29 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* This class tests the Counter1ConstructorStatic class.
*
* @author {user}
* Course: COMP B11
* Created: Apr 23, 2017
* Source File: Counter1ConstructorStaticTester.java
*/
public class Counter1ConstructorStaticTester {
public static void main(String[] args) {
Counter1ConstructorStatic[] counters = new Counter1ConstructorStatic[10];
System.out.printf("Number of Counter1ConstructorStatic objects = %d\n",
Counter1ConstructorStatic.getNumCounters());
counters[0] = new Counter1ConstructorStatic();
System.out.printf("Number of Counter1ConstructorStatic objects = %d\n",
Counter1ConstructorStatic.getNumCounters());
for (int i = 1; i < counters.length; ++i) {
counters[i] = new Counter1ConstructorStatic(i);
for (int j = 0; j < i; ++j)
counters[i].count();
}
System.out.printf("Number of Counter1ConstructorStatic objects = %d\n",
Counter1ConstructorStatic.getNumCounters());
for (int i = 0; i < counters.length; ++i) {
System.out.printf("The count for counter %d is %d.\n", i,
counters[i].getValue());
}
}
}