Name___________________________
Quiz 2/25/08
From the Spring exam, modified:
A small non-profit has hired you to help develop a database for its lending
library. Your task is to write the complete code for the instantiable
class LibraryBook, which represents a book in the library. Each library
book keeps track of its title, its call number, the user ID for the person the
book is checked out to, and the number of times it has been checked out. User ID
numbers are positive integers. Implement the following constructor and
methods:
public LibraryBook(String title)
Constructs a LibraryBook object with the given title that has never been checked
out.
public String getTitle()
Returns the title of the book.
public int getUserID()
Returns the user ID for the person to whom the book is checked out or 0 if the
book is
not currently checked out.
public int numberOfCheckOuts()
Returns the number of times the book has been checked out.
public void checkOut(int userID)
Checks out the book to the person with the given userID. You may assume
that the
userID passed in is a positive integer.
public void checkIn()
Checks in this book. Immediately after checking in a book, a call to
getUserID
should return 0.
public boolean isCheckedOut()
Returns true if the book is currently checked out and false otherwise.
No other methods are required. Comments are not required but can be
helpful where your code is
unclear. If something isn't specified, do something reasonable and
comment your assumptions.