done
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* InvalidTestScore is a custom exception for the TestScores class. It is thrown when a score does not fall in valid
|
||||||
|
* range
|
||||||
|
*/
|
||||||
public class InvalidTestScore extends IllegalArgumentException {
|
public class InvalidTestScore extends IllegalArgumentException {
|
||||||
public InvalidTestScore(String message) {
|
public InvalidTestScore(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
|
|||||||
@@ -32,6 +32,26 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
// Main for q1
|
||||||
|
// Test are 2 test score arrays that will throw the exception when we try to get the averages
|
||||||
|
int[] arr1 = {90, 91, -2, 21, 99};
|
||||||
|
int[] arr2 = {90, 91, 101, 21, 99};
|
||||||
|
try{
|
||||||
|
TestScores t1 = new TestScores(arr1);
|
||||||
|
System.out.println(t1.getAverage());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
////
|
||||||
|
try{
|
||||||
|
TestScores t2 = new TestScores(arr2);
|
||||||
|
System.out.println(t2.getAverage());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Main for Q2
|
// Main for Q2
|
||||||
|
|||||||
Reference in New Issue
Block a user