Class SpellBook
java.lang.Object
SpellBook
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToHistory(int studentNumber) Adds a student ID to the rental history of the spell book.Returns the rental history of the spell book.getPrintableForm(boolean longPresent) Returns a printable string representation of the spell book.intintReturns the student ID currently renting the spell book.getTitle()getType()voidsetInventor(String inventor) voidsetSerialNumber(int serialNumber) voidsetStudentRenting(int studentRenting) voidvoid
-
Constructor Details
-
SpellBook
Constructs a newSpellBookwith the specified details.- Parameters:
serialNumber- the unique identifier for the spellbooktitle- the title of the spellbookinventor- the name of the inventor of the spellbooktype- the type of spell the book contains
-
-
Method Details
-
getSerialNumber
public int getSerialNumber() -
getTitle
-
getInventor
-
getType
-
getStudentRenting
public int getStudentRenting()Returns the student ID currently renting the spell book.- Returns:
- the student ID or -1 if not rented
-
getHistory
-
getPrintableForm
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
-
getRentingStatus
-
setSerialNumber
public void setSerialNumber(int serialNumber) -
setTitle
-
setInventor
-
setType
-
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
-