Class CommonErrorChecker
java.lang.Object
CommonErrorChecker
Class for validating common errors in system.
Checks for missing students, missing spellbooks, and rental mismatches.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the spellbook map is empty.booleanChecks if the student map is empty.booleanisMissingSpellbook(int serialNumber) Checks if a spellbook with the given serial number exists.booleanisMissingStudent(int studentNumber) Checks if a student with the given ID exists.booleanspellbookNotRentedByStudent(int serialNumber, int studentNumber) Checks if the specified spellbook is currently rented by the given student.
-
Constructor Details
-
CommonErrorChecker
Constructs aCommonErrorCheckerwith the given student and spellbook maps.- Parameters:
studentMap- map of student IDs toStudentobjectsspellbookMap- map of spellbook serial numbers toSpellBookobjects
-
-
Method Details
-
checkEmptySpellbooks
public boolean checkEmptySpellbooks()Checks if the spellbook map is empty. Prints an error message if no spellbooks are present.- Returns:
trueif an error is found, otherwisefalse
-
checkEmptyStudents
public boolean checkEmptyStudents()Checks if the student map is empty. Prints an error message if no students are present.- Returns:
trueif an error is found, otherwisefalse
-
isMissingStudent
public boolean isMissingStudent(int studentNumber) Checks if a student with the given ID exists. Prints an error message if the student is missing.- Parameters:
studentNumber- the student ID to check- Returns:
trueif the student is missing, otherwisefalse
-
isMissingSpellbook
public boolean isMissingSpellbook(int serialNumber) Checks if a spellbook with the given serial number exists. Prints an error message if the spellbook is missing.- Parameters:
serialNumber- the spellbook serial number to check- Returns:
trueif the spellbook is missing, otherwisefalse
-
spellbookNotRentedByStudent
public boolean spellbookNotRentedByStudent(int serialNumber, int studentNumber) Checks if the specified spellbook is currently rented by the given student. Prints an error message if the rental does not match.- Parameters:
serialNumber- the spellbook serial numberstudentNumber- the student ID- Returns:
trueif the rental is invalid, otherwisefalse
-