Class SpellBook

java.lang.Object
SpellBook

public class SpellBook extends Object
The SpellBook class represents a magical book in a library system. Each spell book has a unique serial number, a title, an inventor, a type, and tracks rental history and current renting status.
  • Constructor Details

    • SpellBook

      public SpellBook(int serialNumber, String title, String inventor, String type)
      Constructs a new SpellBook with the specified details.
      Parameters:
      serialNumber - the unique identifier for the spellbook
      title - the title of the spellbook
      inventor - the name of the inventor of the spellbook
      type - the type of spell the book contains
  • Method Details

    • getSerialNumber

      public int getSerialNumber()
    • getTitle

      public String getTitle()
    • getInventor

      public String getInventor()
    • getType

      public String getType()
    • getStudentRenting

      public int getStudentRenting()
      Returns the student ID currently renting the spell book.
      Returns:
      the student ID or -1 if not rented
    • getHistory

      public List<Integer> getHistory()
      Returns the rental history of the spell book.
      Returns:
      a list of student IDs who have rented the book
    • getPrintableForm

      public String getPrintableForm(boolean longPresent)
      Returns a printable string representation of the spell book. Includes title, inventor, and optionally the type.
      Parameters:
      longPresent - whether to include the type in the output. Optional parameter set to false if not provided.
      Returns:
      a formatted string of the spell book details
    • getPrintableForm

      public String getPrintableForm()
    • getRentingStatus

      public String getRentingStatus()
    • setSerialNumber

      public void setSerialNumber(int serialNumber)
    • setTitle

      public void setTitle(String title)
    • setInventor

      public void setInventor(String inventor)
    • setType

      public void setType(String type)
    • setStudentRenting

      public void setStudentRenting(int studentRenting)
    • addToHistory

      public void addToHistory(int studentNumber)
      Adds a student ID to the rental history of the spell book.
      Parameters:
      studentNumber - the student ID to add