-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntArrayWorkerTester.java
executable file
·104 lines (97 loc) · 3.45 KB
/
IntArrayWorkerTester.java
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
public class IntArrayWorkerTester
{
/** method to test setMatrix */
public static void testSetMatrix()
{
IntArrayWorker worker = new IntArrayWorker();
int[][] nums = {{1, 1, 1} ,{2,2,2}};
worker.setMatrix(nums);
System.out.println("This should have all 1's in first row and all 2's in second");
worker.print();
}
/** Method to test fillPattern1 */
public static void testFillPattern1()
{
IntArrayWorker worker = new IntArrayWorker();
int[][] nums = new int[3][4];
worker.setMatrix(nums);
worker.fillPattern1();
System.out.println("fills with 2's on diagonal, 3's to left, and 1's to right");
worker.print();
}
/** Method to test getCount*/
// public static void testGetCount()
// {
// IntArrayWorker worker = new IntArrayWorker();
// int[][] nums = new int[3][4];
// worker.setMatrix(nums);
// worker.fillPattern1();
// int count = worker.getCount(1);
// System.out.println("Count should be 6 and count is " + count);
// }
/** Method to test getTotal */
public static void testGetTotal()
{
IntArrayWorker worker = new IntArrayWorker();
int [][] nums2 = {{1, 2, 3}, {4, 5, 6}};
worker.setMatrix(nums2);
int total = worker.getTotal();
System.out.println("Total should be 21 and is " + total);
}
/** Method to test getTotalNested */
public static void testGetTotalNested()
{
IntArrayWorker worker = new IntArrayWorker();
int [][] nums2 = {{1, 2, 3}, {4, 5, 6}};
worker.setMatrix(nums2);
int total = worker.getTotalNested();
System.out.println("Total should be 21 and is " + total);
}
/** Method to test getLargest */
// public static void testGetLargest()
// { // test when largest is last
// IntArrayWorker worker = new IntArrayWorker();
// int [][] nums2 = {{1, 2, 3}, {4, 5, 6}};
// worker.setMatrix(nums2);
// int largest = worker.getLargest();
// System.out.println("Largest should be 6 and is " + largest);
// // test when largest is first
// int[][] nums3 = {{6, 2, 3}, {4, 5, 1}};
// worker.setMatrix(nums3);
// largest = worker.getLargest();
// System.out.println("Largest should be 6 and is " + largest);
// // test when largest is in the middle
// int[][] nums4 = {{1, 2, 3}, {6, 5, 1}};
// worker.setMatrix(nums4);
// largest = worker.getLargest();
// System.out.println("Largest should be 6 and is " + largest);
// // test when duplicate largest
// int[][] nums5 = {{6, 2, 6}, {4, 5, 1}};
// worker.setMatrix(nums5);
// largest = worker.getLargest();
// System.out.println("Largest should be 6 and is " + largest);
// }
/** Method to test getColTotal */
// public static void testGetColTotal()
// {
// IntArrayWorker worker = new IntArrayWorker();
// int [][] nums2 = {{1, 2, 3}, {4, 5, 6}};
// worker.setMatrix(nums2);
// int total = worker.getColTotal(0);
// System.out.println("Total for column 0 should be 5 and is " + total);
// total = worker.getColTotal(1);
// System.out.println("Total for column 1 should be 7 and is " + total);
// total = worker.getColTotal(2);
// System.out.println("Total for column 2 should be 9 and is " + total);
// }
public static void main(String[] args)
{
testSetMatrix();
testFillPattern1();
//testGetCount();
testGetTotal();
testGetTotalNested();
//testGetLargest();
//testGetColTotal();
}
}