diff --git a/src/main/java/tutorlink/storage/ComponentStorage.java b/src/main/java/tutorlink/storage/ComponentStorage.java index 5c80e1825d..87b1514964 100644 --- a/src/main/java/tutorlink/storage/ComponentStorage.java +++ b/src/main/java/tutorlink/storage/ComponentStorage.java @@ -13,6 +13,7 @@ * The file contains data on each component with its name, maximum score, and weight. */ public class ComponentStorage extends Storage { + private static final double MAX_SCORE = 10000.0; /** * Constructs a {@code ComponentStorage} with the specified file path. @@ -87,7 +88,7 @@ private Component getComponentFromFileLine( throw new InvalidDataFileLineException(fileLine); } - boolean isValidMaxScore = (maxScore >= 0); + boolean isValidMaxScore = (maxScore >= 0 && maxScore <= MAX_SCORE); boolean isValidWeight = (weight >= 0 && (weight + totalWeight) <= 100); Component newComponent = new Component(name, maxScore, weight); if (!isValidMaxScore || !isValidWeight || components.contains(newComponent)) { diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index 77255da9d3..495162ed88 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -1,4 +1,21 @@ ------------------------------------------------------------- +Discarded student data: + A1111111B| John Smith + A1111111B | John Smith + A123B | Beth +------------------------------------------------------------- +Discarded component data: + Attendance | 5 | 5 + Finals | 80 | 96 + Test 1 | 10 | -0.1 + Test 2 | -0.01 | 5 + Test 3 | 10000.01 | 5 +------------------------------------------------------------- +Discarded grade data: + Attendance | A1111111B | 5.01 + Attendance | A1111111B | 4 + Attendance | A1111111B | 4 +------------------------------------------------------------- ___________ __ .____ .__ __ \__ ___/_ ___/ |_ ___________| | |__| ____ | | __ | | | | \ __\/ _ \_ __ \ | | |/ \| |/ / diff --git a/text-ui-test/data_init/componentlist.txt b/text-ui-test/data_init/componentlist.txt index 16efe0f58e..b3f9e6d361 100644 --- a/text-ui-test/data_init/componentlist.txt +++ b/text-ui-test/data_init/componentlist.txt @@ -1 +1,6 @@ Attendance | 5 | 5 + Attendance | 5 | 5 +Finals | 80 | 96 +Test 1 | 10 | -0.1 +Test 2 | -0.01 | 5 +Test 3 | 10000.01 | 5 diff --git a/text-ui-test/data_init/gradelist.txt b/text-ui-test/data_init/gradelist.txt index 779f504ca5..e5143870c3 100644 --- a/text-ui-test/data_init/gradelist.txt +++ b/text-ui-test/data_init/gradelist.txt @@ -1 +1,4 @@ +Attendance | A1111111B | 5.01 Attendance | A1111111B | 4 +Attendance | A1111111B | 4 + Attendance | A1111111B | 4 diff --git a/text-ui-test/data_init/studentlist.txt b/text-ui-test/data_init/studentlist.txt index 12c2ec5bbd..30afd5fecc 100644 --- a/text-ui-test/data_init/studentlist.txt +++ b/text-ui-test/data_init/studentlist.txt @@ -1 +1,4 @@ +A1111111B| John Smith A1111111B | John Smith + A1111111B | John Smith +A123B | Beth