Class Book2

java.lang.Object
  |
  +--Book2

public class Book2
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable

Book2 class, which is misnomer because it really has the functionality of BookInLibrary (info about book per se plus info about status of one copy of that book in some particular library). Date started 2004.Oct.04 for Lab#1, amended for Lab#2 starting Oct.26 Part of Blab2.java (Second = 035B Java college-class, lab assignment #2)

Author:
Robert Elton Maas
See Also:
Serialized Form

Field Summary
private  java.lang.String author
           
private  int bkid
           
private  java.util.Calendar duedate
           
private  java.lang.String isbn
           
private  java.lang.String loanedTo
           
private  java.util.Vector reservedBy
           
(package private) static long serialVersionUID
           
private  java.lang.String title
           
 
Constructor Summary
Book2(int bkid, java.lang.String title, java.lang.String author, java.lang.String isbn)
          Make new book record, not checked out, no due date yet.
 
Method Summary
 void addReservedBy(java.lang.String ptid)
          Add one patron to reserve list for book
static java.lang.String calendarToString(java.util.Calendar cal)
          Convert Calendar object to string in legible format.
 void clearLoaned()
          Set status of this book as no longer loaned out
 int compareTo(java.lang.Object bk2)
          Compare two books, to implement Comparable interface.
 int countReservedBy()
          Count how many reservations on this one book.
 java.lang.String getAuthor()
          Accessor for author of book
 java.util.Calendar getDuedate()
          Get date when this book is due
 java.lang.String getFirstReservedBy()
          Get first patron who has reserved this book
 int getId()
          Accessor for ID of book in library
 java.lang.String getIsbn()
          Accessor for ISBN of book
 java.lang.String getLoanedTo()
          Get patron who currently has this book checked out.
 java.util.Enumeration getReservedBy()
          Make enumeration of reserved list for book.
 java.lang.String getTitle()
          Accessor for title of book
 boolean isLoaned()
          Is this book loaned out currently?
 void removeReservedBy(java.lang.String ptid)
          Remove one patron from reserve list for book
 void setDuedate(java.util.Calendar dd)
          Set date when this book is due
 void setLoaned(java.lang.String pid)
          Set status of this book as loaned out to patron
 java.lang.String toString()
          Make printable string, including legible date, describing the book.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID

title

private java.lang.String title

author

private java.lang.String author

isbn

private java.lang.String isbn

bkid

private int bkid

loanedTo

private java.lang.String loanedTo

duedate

private java.util.Calendar duedate

reservedBy

private java.util.Vector reservedBy
Constructor Detail

Book2

public Book2(int bkid,
             java.lang.String title,
             java.lang.String author,
             java.lang.String isbn)
Make new book record, not checked out, no due date yet.
Parameters:
bkid - Library's ID number for book
title - Title of book
author - Name of author of book
isbn -  
Method Detail

compareTo

public int compareTo(java.lang.Object bk2)
Compare two books, to implement Comparable interface.
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
bk2 - Second book, compared against this book

countReservedBy

public int countReservedBy()
Count how many reservations on this one book.
Returns:
int Number of reservations on this book

getReservedBy

public java.util.Enumeration getReservedBy()
Make enumeration of reserved list for book.
Returns:
Enumeration of reservations of this one book

getFirstReservedBy

public java.lang.String getFirstReservedBy()
Get first patron who has reserved this book
Returns:
String card# of first patron on reserve list for this book.

removeReservedBy

public void removeReservedBy(java.lang.String ptid)
Remove one patron from reserve list for book
Parameters:
ptid - String card# of patron to be removed

addReservedBy

public void addReservedBy(java.lang.String ptid)
Add one patron to reserve list for book
Parameters:
ptid - String card# of patron to reserve this book

getLoanedTo

public java.lang.String getLoanedTo()
Get patron who currently has this book checked out.
Returns:
String card# of patron who has this book checked out

isLoaned

public boolean isLoaned()
Is this book loaned out currently?
Returns:
boolean true if book loaned out, false if on shelf

setLoaned

public void setLoaned(java.lang.String pid)
Set status of this book as loaned out to patron
Parameters:
pid - String card# of patron who is checking out this book now

clearLoaned

public void clearLoaned()
Set status of this book as no longer loaned out

getDuedate

public java.util.Calendar getDuedate()
Get date when this book is due
Returns:
Calendar Date when this book is due to be returned

setDuedate

public void setDuedate(java.util.Calendar dd)
Set date when this book is due
Parameters:
dd - Calendar Date when this book is due to be returned

getAuthor

public java.lang.String getAuthor()
Accessor for author of book
Returns:
String author of book

getTitle

public java.lang.String getTitle()
Accessor for title of book
Returns:
String title of book

getId

public int getId()
Accessor for ID of book in library
Returns:
int ID of book

getIsbn

public java.lang.String getIsbn()
Accessor for ISBN of book
Returns:
String ISBN of book

calendarToString

public static java.lang.String calendarToString(java.util.Calendar cal)
Convert Calendar object to string in legible format.
Parameters:
cal - Calendar object with some date&time contained within.
Returns:
String showing date&time in legible format.

toString

public java.lang.String toString()
Make printable string, including legible date, describing the book.
Overrides:
toString in class java.lang.Object
Returns:
The printable string.