Skip to content

Commit 3b4b806

Browse files
committed
Added tester for mmn14
1 parent 6cb51c5 commit 3b4b806

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Testers/ממן14/Tester.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
public class Tester {
2+
final static String GOOD = "\t\t\t OK!";
3+
final static String BAD = "\t\t\t *** Bummer you're wrong! ***";
4+
5+
public static void main(String[] args) {
6+
System.out.println("******************************************");
7+
System.out.println("*** ***");
8+
System.out.println("*** MMN14 Tester ***");
9+
System.out.println("*** ***");
10+
System.out.println("******************************************");
11+
System.out.println();
12+
Ex14 ex14 = new Ex14();
13+
14+
/* Question 1 */
15+
System.out.println("Question 1: ");
16+
int[] arr = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; // 0
17+
int[] arr2 = {9, 8, 7, 6, 5, 4, 3, 2, 3}; // 1
18+
int[] arr3 = {1, 2, 3, 4, 5, 6, 7, 8, 9}; // 0
19+
int[] arr4 = {2, 1, 1, 20, 1, 1, 2, 3}; // 7
20+
int[] arr5 = {2, 1, 5, 1, 4, 1, 1, 1, 2}; // 7
21+
int[] arr6 = {9, 8, 7, 6, 5, 4, 3, 2, 1}; // 0
22+
int[] arr7 = {1, 5, 4, 3, 2, 1, 3, 3, 3, 3, 2, 1, 2, 6, 6, 5, 4, 3, 2, 1}; // 28
23+
boolean trapWater = (ex14.waterVolume(arr) == 0) && (ex14.waterVolume(arr2) == 1) &&
24+
(ex14.waterVolume(arr3) == 0) && (ex14.waterVolume(arr4) == 7) && (ex14.waterVolume(arr5) == 7) &&
25+
(ex14.waterVolume(arr6) == 0) && (ex14.waterVolume(arr7) == 28);
26+
if(trapWater)
27+
System.out.println(GOOD);
28+
else
29+
System.out.println(BAD);
30+
}
31+
}

0 commit comments

Comments
 (0)