org.jwalk.test
Class LibraryBook

java.lang.Object
  extended by org.jwalk.test.LibraryBook
Direct Known Subclasses:
ReservableBook

public class LibraryBook
extends java.lang.Object

A simple LibraryBook that can be issued and discharged on loan to a borrower. One borrower at a time is allowed; the object exists in two states: Default and OnLoan.

Version:
1.0
Author:
Anthony Simons

Constructor Summary
LibraryBook()
          Constructs a LibraryBook in its default state.
 
Method Summary
 void discharge()
          Discharges the loan of this LibraryBook.
 java.lang.String getBorrower()
          Returns the name of the current borrower, or null.
 boolean isOnLoan()
          Reports if this LibraryBook is on loan.
 void issue(java.lang.String person)
          Issues this LibraryBook to the named person.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LibraryBook

public LibraryBook()
Constructs a LibraryBook in its default state.

Method Detail

issue

public void issue(java.lang.String person)
           throws java.lang.Exception
Issues this LibraryBook to the named person. Only issues the book if it is not already on loan to someone else, otherwise raises a exception.

Throws:
java.lang.Exception

discharge

public void discharge()
Discharges the loan of this LibraryBook. Has no effect if this LibraryBook is not already on loan (a null operation).


getBorrower

public java.lang.String getBorrower()
Returns the name of the current borrower, or null.


isOnLoan

public boolean isOnLoan()
Reports if this LibraryBook is on loan.