Task

You are to create a new computerised library management system to replace the old one. This description details the requirements of the new system. The Library System will consist of two main components, an administrative component, and a catalogue. The administrative section will allow, through text-based menus, the addition and removal of patrons, the addition and removal of books in the catalogue, the display of patron records and the display of a patron's 3 favourite books. The catalogue will store a list of all the books in the library, a list of the genres of those books, a list of all the authors with books in the library and a list of the books on loan. The catalogue will also allow the display of the books in a number of ways, including by availability, genre and author. Finally, the catalogue will also handle the borrowing and return of books, and the placing of holds on books. Each patron record will include the patrons name, their chosen ID number, which books they are currently borrowing and their full borrowing history. Each book record will include the books title, its author and its genre.

Topics

OO Design, Standard Patterns, Lists

Requirements

Your design will consist of exactly the following classes with the listed fields, declared as indicated. You may not add or remove classes or fields, however you may add constructors, functions and procedures to complete your design. Any violation of the requirements will result in mark deduction and will be shown in the manual feedback.

To help visualise the design, a partial class diagram has been provided - This doesn't have everything you need. see image.

Fields

  • Lists all have the abstract type of List< >, but must be instantiated with a concrete type that implements the List< > behaviour
  • The name String in Genre is stored in lowercase

Constructors

  • All constructors initialise the fields of their class
  • The Library constructor takes no parameters
  • The Catalogue constructor takes a single parameter, the Library which it belongs to
  • The Patron constructor takes two parameters, the ID and name, corresponding to the two fields identically named
  • The Book constructor takes three parameters, corresponding to the title, author and genre, with the same types as the respective fields
  • The Genre constructor takes a single parameter, the name of the genre
  • The Author constructor takes a single parameter, the name of the author

toString()

  • Patron.toString() will produce a string of the form: < ID> < name> e.g. 25 Jack Smith
  • Book.toString() will produce a string of the form: < Author's name>, < Title> e.g. Joshua Bloch, Effective Java
  • Genre.toString() will produce a string of the form: < genre name> e.g. new weird
  • Author.toString() will simply produce the author's name

The main method of the program will be in the Library class.

Holds- the library should also implement a hold system.

  • A patron may request a book to be held for them. If a book has any holds, it may not be loaned out to any other patron except the first patron on the hold list
  • Holds are processed sequentially, so multiple patrons may place a hold, and whoever gets in first must be the next to borrow it. A single patron may only place a single hold on a particular book - if they're already in the list, then thats all they get
  • A hold may only be cleared when that patron borrows the book.

Advanced Requirements

To achieve a mark of >84, you must implement a favourites reporting function (or set of functions). This corresponds to an item in the main menu (see the trace above). Choosing this option should prompt the user for a valid patron ID, and then display the user's 3 most borrowed books, in order of highest borrowing frequency to lowest. If the user has only borrowed less than three books, it will show those books alone.

User Interface

Below is a sample I/O trace. The bold text indicates user input (you are not expected to print bold text). Not every conceivable scenario is shown below.

Welcome to the Library! Please make a selection from the menu:
1. Explore the catalogue.
2. View your patron record.
3. Show you favourite books.
4. Enter Admin Mode.
X. Exit the system.
Enter a choice: 4

Welcome to the administration menu:
1. Add a patron.
2. Remove a patron.
3. Add a book to the catalogue.
4. Remove a book from the catalogue.
R. Return to the previous menu.
Enter a choice: 1

Adding a new patron.
Enter a new ID: 42
Enter the patron's name: Angela Huo
Patron added.

Welcome to the administration menu:
1. Add a patron.
2. Remove a patron.
3. Add a book to the catalogue.
4. Remove a book from the catalogue.
R. Return to the previous menu.
Enter a choice: 3

Adding a new book.
Enter the title of the book: Effective Java
Enter the author's name: Joshua Bloch
Enter the genre: reference
Added Effective Java to catalogue.

Welcome to the administration menu:
1. Add a patron.
2. Remove a patron.
3. Add a book to the catalogue.
4. Remove a book from the catalogue.
R. Return to the previous menu.
Enter a choice: R
Welcome to the Library! Please make a selection from the menu:
1. Explore the catalogue.
2. View your patron record.
3. Show you favourite books.
4. Enter Admin Mode.
X. Exit the system.
Enter a choice: 1
Welcome to the Catalogue! Please make a selection from the
menu:
1. Display all books.
2. Display all available books.
3. Display all genres.
4. Display books in a genre.
5. Display all authors.
6. Display all books by an author.
7. Borrow a book.
8. Return a book.
9. Place a hold.
R. Return to previous menu.
Enter a choice: 1

The Library has the following books:
Joshua Bloch, Effective Java

Welcome to the Catalogue! Please make a selection from the
menu:
1. Display all books.
2. Display all available books.
3. Display all genres.
4. Display books in a genre.
5. Display all authors.
6. Display all books by an author.
7. Borrow a book.
8. Return a book.
9. Place a hold.
R. Return to previous menu.
Enter a choice: 3

The Library has books in the following genres:
reference

Welcome to the Catalogue! Please make a selection from the menu:
1. Display all books.
2. Display all available books.
3. Display all genres.
4. Display books in a genre.
5. Display all authors.
6. Display all books by an author.
7. Borrow a book.
8. Return a book.
9. Place a hold.
R. Return to previous menu.
Enter a choice: 5

The following authors have books in this Library:
Joshua Bloch

Welcome to the Catalogue! Please make a selection from the menu:
1. Display all books.
2. Display all available books.
3. Display all genres.
4. Display books in a genre.
5. Display all authors.
6. Display all books by an author.
7. Borrow a book.
8. Return a book.
9. Place a hold.
R. Return to previous menu.
Enter a choice: 7

Enter a valid patron ID: 42
Enter the title of the book you wish to borrow: Effective Java
Book loaned.

Welcome to the Catalogue! Please make a selection from the menu:
1. Display all books.
2. Display all available books.
3. Display all genres.
4. Display books in a genre.
5. Display all authors.
6. Display all books by an author.
7. Borrow a book.
8. Return a book.
9. Place a hold.
R. Return to previous menu.
Enter a choice: 2

The following books are on the shelf:

Welcome to the Catalogue! Please make a selection from the menu:
1. Display all books.
2. Display all available books.
3. Display all genres.
4. Display books in a genre.
5. Display all authors.
6. Display all books by an author.
7. Borrow a book.
8. Return a book.
9. Place a hold.
R. Return to previous menu.
Enter a choice: 8

Enter a valid patron ID: 42
Luke Mathieson has the following books:
Books currently borrowed by Angela Huo:
Joshua Bloch, Effective Java
Enter the title of the book you wish to return: Effective Java
Effective Java has been returned.

Welcome to the Catalogue! Please make a selection from the menu:
1. Display all books.
2. Display all available books.
3. Display all genres.
4. Display books in a genre.
5. Display all authors.
6. Display all books by an author.
7. Borrow a book.
8. Return a book.
9. Place a hold.
R. Return to previous menu.
Enter a choice: R

Welcome to the Library! Please make a selection from the menu:
1. Explore the catalogue.
2. View your patron record.
3. Show you favourite books.
4. Enter Admin Mode.
X. Exit the system.
Enter a choice: x

A sample partial I/O trace for Advanced Requirements:

Welcome to the Library! Please make a selection from the menu:
1. Explore the catalogue.
2. View your patron record.
3. Show you favourite books.
4. Enter Admin Mode.
X. Exit the system.
Enter a choice: 3
Enter a patron ID: 42
Angela Huo's favourite books are:
David Foster Wallace, Infinite Jest
Tim Powers, The Anubis Gates
Christopher Priest, The Islanders
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.