Class Blab2

java.lang.Object
  |
  +--Blab2

public class Blab2
extends java.lang.Object

Blab2 (Second = 035B Java college-class, lab assignment #2) Set up a crude library system with only a few customers. Date started: 2004.Oct.04 for Lab#1, amended for Lab#2 from Oct.26

Author:
Robert Elton Maas

Constructor Summary
Blab2()
           
 
Method Summary
private static int askId(boolean newflg)
          Ask user for book ID.
private static boolean checkCommand(java.lang.String userstr, java.lang.String cmdstr, int minchars)
          Compare user command string against correct command string for some particular command.
private static void cmdAddNewBook()
          Implements the Add new book command
private static void cmdCheckOutBook(Patron pt)
          Implements the Check out book command
private static void cmdDelete()
          Implements the Delete book command
private static void cmdInfoListing(Patron pt)
          For one patron, implementation of command to list all info about that patron.
private static void cmdListAllBooks()
          Implements the List all books command
private static void cmdListOverdueBooks()
          Implements the list Overdue books command
private static void cmdNewPatron()
          Implements command to add a new patron and assign library card.
private static void cmdPatronLogin()
          For commands related to a single patron, ask for card# then enter patron command loop.
private static void cmdPayFine(Patron pt)
          Allows patron to pay fine and thereby deduct amount owed
private static void cmdRenewBook()
          Implements the Renew book command
private static void cmdReserveBook(Patron pt)
          Implements patron command to reserve a book
private static void cmdReturnBook()
          Implements the Return book command
private static void cmdSearchAuthor()
          Implements command to search by author and print all info about all books found.
private static void cmdSearchTitle()
          Implements command to search by title and print all info about all books found.
private static void cmdXpellPatron()
          Implements command to eXpel (delete all info about) a patron, checking first to make sure no pending matters such as book still checked out or fine owed.
private static void commandLoop()
          Main command loop: Issues prompt, waits for user to type line of input, matches typed-command against available command, dispatches to appropriate command handler.
static void main(java.lang.String[] args)
          main method loads database, runs command loop, saves database on exit
private static void printCommands()
          Prints list of available user commands for main command loop
private static void printPatronCommands()
          Print list of commands in regard to one patron
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

Blab2

public Blab2()
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        java.io.StreamCorruptedException,
                        java.io.OptionalDataException,
                        java.lang.ClassNotFoundException
main method loads database, runs command loop, saves database on exit
Parameters:
args - Not used

cmdInfoListing

private static void cmdInfoListing(Patron pt)
For one patron, implementation of command to list all info about that patron.
Parameters:
pt - Patron The full Patron record

printPatronCommands

private static void printPatronCommands()
Print list of commands in regard to one patron

cmdDelete

private static void cmdDelete()
Implements the Delete book command

cmdReturnBook

private static void cmdReturnBook()
Implements the Return book command

cmdRenewBook

private static void cmdRenewBook()
Implements the Renew book command

cmdListOverdueBooks

private static void cmdListOverdueBooks()
Implements the list Overdue books command

cmdCheckOutBook

private static void cmdCheckOutBook(Patron pt)
Implements the Check out book command

cmdListAllBooks

private static void cmdListAllBooks()
Implements the List all books command

cmdAddNewBook

private static void cmdAddNewBook()
Implements the Add new book command

askId

private static int askId(boolean newflg)
Ask user for book ID. Check whether such book alredy in library.
Parameters:
newflg - If true, user input accepted only if book is new, not already in library. If false, user input accepted only if book is old, already in library.
Returns:
For new book, the ID entered by user. For old book, the index in the list of books where ID found. If user gives up, -1.

checkCommand

private static boolean checkCommand(java.lang.String userstr,
                                    java.lang.String cmdstr,
                                    int minchars)
Compare user command string against correct command string for some particular command.
Parameters:
userstr - String entered by user.
cmdstr - Full name of command to match.
minchars - Minimum length of user string allowed.
Returns:
True if user input at least minchars and all of it matches cmdstr.

cmdPatronLogin

private static void cmdPatronLogin()
For commands related to a single patron, ask for card# then enter patron command loop.

cmdPayFine

private static void cmdPayFine(Patron pt)
Allows patron to pay fine and thereby deduct amount owed
Parameters:
pt - Patron Full patron record

cmdReserveBook

private static void cmdReserveBook(Patron pt)
Implements patron command to reserve a book
Parameters:
pt - Patron Full patron record

cmdNewPatron

private static void cmdNewPatron()
Implements command to add a new patron and assign library card.

cmdXpellPatron

private static void cmdXpellPatron()
Implements command to eXpel (delete all info about) a patron, checking first to make sure no pending matters such as book still checked out or fine owed. All book reservations are cancelled.

cmdSearchAuthor

private static void cmdSearchAuthor()
Implements command to search by author and print all info about all books found.

cmdSearchTitle

private static void cmdSearchTitle()
Implements command to search by title and print all info about all books found.

commandLoop

private static void commandLoop()
Main command loop: Issues prompt, waits for user to type line of input, matches typed-command against available command, dispatches to appropriate command handler.

printCommands

private static void printCommands()
Prints list of available user commands for main command loop