IT 220 Library Assignment

Overview

For this assignment, you will be creating a library system that allows users to search for books or CDs, check out items, and display a list of the items they have checked out. This system is designed for a single user, but could be expanded to accommodate multiple users.

Learning outcomes: Inheritance and polymorphism, interfaces, file I/O, console I/O.

The Library Hierarchy

The classes in the inheritance hierarchy for the Library system are shown below. Note that Loanable and Comparable are interfaces, and Item is an abstract class. The Comparable interface already exists. You will not be creating it.

 

The Item Class

The abstract Item class represents an item in the library. Each item has a numeric item number, a title, and a check out date. The Item class has the following methods:

 

The Book and CD Classes

The Book and CD classes override loanPeriod(), which is inherited from Loanable. The loan period for a book is 30 days, and the loan period for a CD is 14 days. The loanPeriod() methods will simply return a value. However, you can imagine an implementation where the loan period is calculated based on the type of library patron, the number of items checked out or on hold, or some other criteria.

The Files

There are two files for this assignment, library.txt and checked-out.txt. The library.txt file stores all of the items currently in the library. There are 112 items currently in the file, but you are welcome to add your own! The items the user currently has checked out are stored in checked-out.txt. Note that the checked out file contains the checked out date, while the library file does not. When the user exits the program, the checked-out.txt file will be overwritten with the users currently checked out items.

Make sure that your files are stored in a files directory.

Here are snippets from the files:

library.txt

1004^cd^Adele^25
1005^cd^Sam Hunt^Montevallo
1006^cd^Drake^Views
1007^book^Ballard^One Shot at Forever^True story about a high school baseball team in Illinois...
1008^book^Bascomb^Nazi Hunters^A Bluegrass award book that is non-fiction and is about the capture...
1009^book^Bemis^Nine pound hammer^Ray and his little sister are orphans and are on a train bound for...

checked-out.txt

998^cd^Alabama Shakes^Sound & Color^2016-05-03
999^cd^Walk the Moon^Talking is Hard^2016-04-28
1007^book^Ballard^One Shot at Forever^True story about a high school baseball team in Illinois-...^2016-04-10
1008^book^Bascomb^Nazi Hunters^A Bluegrass award book that is non-fiction and is about the capture...^2016-05-11

The Library Class

A Library class will define your application logic.

The Library class data includes the following:

Library class methods are described as follows:

The Driver Class

Create a driver class that instantiates a Library object. Then, display the menu and respond to the user's selection until the user chooses to Exit.

Javadoc

Generate Javadoc documentation for all of your classes. Include the "doc" folder as part of your zipped Eclipse project.

Sample Run

Sample output for the library application is shown below.

MAIN MENU 
--------- 
[S]earch the library 
[C]heck out an item 
[P]rint my items 
e[X]it  

Your selection: p  

Your items: 
1008 - Book: Nazi Hunters, Bascomb. Date due: 2016-06-10 
1007 - Book: One Shot at Forever, Ballard. Date due: 2016-05-10 OVERDUE 
998 - CD: Sound & Color, Alabama Shakes. Date due: 2016-05-17 
999 - CD: Talking is Hard, Walk the Moon. Date due: 2016-05-12 OVERDUE  

MAIN MENU 
--------- 
[S]earch the library 
[C]heck out an item 
[P]rint my items 
e[X]it  

Your selection: m  
Invalid selection.  

Your selection: s  

Enter search term: queen  

Search results:  
1001 - CD: Greatest Hits, Queen 
1025 - Book: The Queen, Cass  

MAIN MENU 
--------- 
[S]earch the library 
[C]heck out an item 
[P]rint my items 
e[X]it  
 
Your selection: c  

Item Number to check out: 1001 
You have successfully checked out 1001 - CD: Greatest Hits, Queen. Date due: 2016-05-25  

MAIN MENU 
--------- 
[S]earch the library 
[C]heck out an item 
[P]rint my items 
e[X]it  

Your selection: C  

Item Number to check out: 1001 
You already have that item checked out.  

MAIN MENU 
--------- 
[S]earch the library 
[C]heck out an item 
[P]rint my items 
e[X]it  

Your selection: c  

Item Number to check out: 2000 
Item 2000 was not found.  

MAIN MENU 
--------- 
[S]earch the library 
[C]heck out an item 
[P]rint my items 
e[X]it  

Your selection: P  

Your items:  
1008 - Book: Nazi Hunters, Bascomb. Date due: 2016-06-10 
1007 - Book: One Shot at Forever, Ballard. Date due: 2016-05-10 OVERDUE 
1001 - CD: Greatest Hits, Queen. Date due: 2016-05-25
998 - CD: Sound & Color, Alabama Shakes. Date due: 2016-05-17 
999 - CD: Talking is Hard, Walk the Moon. Date due: 2016-05-12 OVERDUE

MAIN MENU 
--------- 
[S]earch the library 
[C]heck out an item 
[P]rint my items 
e[X]it  

Your selection: x  

Goodbye!