Class CommonErrorChecker

java.lang.Object
CommonErrorChecker

public class CommonErrorChecker extends Object
Class for validating common errors in system. Checks for missing students, missing spellbooks, and rental mismatches.
  • Constructor Details

    • CommonErrorChecker

      public CommonErrorChecker(Map<Integer,Student> studentMap, Map<Integer, SpellBook> spellbookMap)
      Constructs a CommonErrorChecker with the given student and spellbook maps.
      Parameters:
      studentMap - map of student IDs to Student objects
      spellbookMap - map of spellbook serial numbers to SpellBook objects
  • Method Details

    • checkEmptySpellbooks

      public boolean checkEmptySpellbooks()
      Checks if the spellbook map is empty. Prints an error message if no spellbooks are present.
      Returns:
      true if an error is found, otherwise false
    • checkEmptyStudents

      public boolean checkEmptyStudents()
      Checks if the student map is empty. Prints an error message if no students are present.
      Returns:
      true if an error is found, otherwise false
    • 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:
      true if the student is missing, otherwise false
    • 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:
      true if the spellbook is missing, otherwise false
    • 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 number
      studentNumber - the student ID
      Returns:
      true if the rental is invalid, otherwise false