The Problem

FCIT is introducing a new service for FCIT students. It is starting a book loaning service, FCIT Library. FCIT Library provides textbooks for all courses in the College. FCIT students are automatically eligible to use this service. However, the library is on a tight budget; there are exactly three books available for each course! So, for example, once three students have borrowed the course textbook for Data Structures, no other student can borrow that book until at least one of those students returns the book to the library.

FCIT Library is in need of a program that:

Keeps track of all textbooks for FCIT courses.
Keeps track of students who are allowed to borrow books from the FCIT Library.
These students must be added to, or removed from, the FCIT Library system.
Additionally, students can borrow books and return them at their convenience.

During the program, the following things can occur (just as in a normal library):

New students can be added to the enrolled group of students. For example, perhaps a student transferred from another faculty. So this new student can be added as a new student who can borrow books from FCIT Library.

New Textbooks can be added to the list of FCIT Library books. For example, perhaps the library doesn't initially own the CPCS204 new textbook. So this new book, the CPCS204 book, can be added as a new book for FCIT Library. Note: when new books are added for the first time, they are initialized with a quantity of 3, and it is immediately set to "Available".

Students can come throughout the day to borrow books from the library. If the book is available, the student will borrow the book. The book will be marked as unavailable, and the ID of the student will be saved into the record of the book (to show which student borrowed the book).

Students can only borrow a maximum of 5 books at a time. Meaning, once a student has 5 books in their possession, they cannot borrow any more books until they first return some books. So, for example, if they return 2 books, they are allowed to borrow 2 more books. However, they can borrow at most 5 books at any given time. Students will also return books that they borrowed. When a student returns a book, the book is immediately marked as available, and the student information should be removed from the record of the book.

A search can be conducted to find information about books.

Also, a search can be done to display the information for a certain student and list all the books he/she is currently borrowing.

You will use File I/O to read input from a file and then print the output to a file. To be clear, you will read COMMANDS from an input file. Example commands are ADDSTUDENT, ADDBOOK, BORROWBOOK, etc. Then, depending on the command, you will either add a new student or book, have a student borrow a book, search for a book, etc. But instead of printing to the console window (screen), you will print to an output file.

*Sample input and output files have been provided for you on Blackboard.

Implementation

For this program, you will create two Classes (UML diagram shown below): see image.

You will use the FCITstudent class to create nodes of type FCITstudent, and you will use the FCITbook class to create nodes of type FCITbook, which of course are used to represent the books in the FCIT Library.

And you will also have two Classes for the two different types of linked lists:

1.You will have a linked-list of FCITstudent objects (FCITstudentsLL.java)
2.You will also have a linked-list of FCITbook objects (FCITbooksLL.java)

Therefore, you will need two separate linked-lists classes. These two classes will be mostly the same; any differences will come from the different functionality as described later in this write-up. The major difference will be that the head variable for the FCITstudentsLL.java class will be a reference to a FCITstudent object, and the head variable for the FCITbooksLL.java class will be a reference to a FCITbook object.

Whenever you see an ADDBOOK command, you will make a new object of type FCITbook, you will scan the needed data from the file, and you will then insert that new object/node into the linked-list of FCITbooks. And whenever you see an ADDSTUDENT command, you will make a new object of type FCITstudent, you will scan the needed data from the file, and you will then inset that new object/node into the linked-list of FCITstudents.

Input File Specifications

You will read in input from a file, "FCITlibrary.in". Have this AUTOMATED. Do not ask the user to enter "FCITlibrary.in". You should read in this automatically.

Each line of input will have a command, which is then followed by relevant data as described below (and this relevant data will be on the same line as the command).

The commands you will have to implement are as follows:

ADDSTUDENT - Adds a new student to the library registry. The command will be followed by the following information all on the same line: ID, an integer representing the student ID number; firstName, a string representing the student first name; and lastName, another string for student last name.

When you read the ADDSTUDENT command, you must make a new object of type FCITstudent. Next, you must scan the additional information (listed above) and save this information into the correct data members of the new object. Each item will be unique. Meaning, the input file is guaranteed to not have duplicate items added to the library student registry via the ADDSTUDENT command. Finally, you must insert this new student into the linked-lists of students.

*Note: this linked list must be sorted based on the ID of the student, with the largest ID coming first in the linked list. So the student with the "biggest" ID will come first, and the student with the smallest ID will come last. Therefore, this list will be in descending order.

ADDBOOK - Adds a new book to the FCIT Library. The command will be followed by the following information all on the same line: ID, an integer representing the book ID number (ISBN); name, a string representing the name of the book (the name is guaranteed to not have any spaces in itso it is easy to read); firstName, a string representing the first name of the author; and lastName, another string for student last name of the author. Finally, you must insert this new book into the linked-lists of books.

*Note: this linked list must be sorted based on the name of the book. Therefore, this list is sorted, alphabetically. You should use the JAVA compareToIgnoreCase String method to compare the names of the books and decide which one comes earlier.

BORROWBOOK - This command is for students requesting to borrow a book. The command will be followed by the following information all on the same line: student ID, an integer representing the ID of the student borrowing the book, and book ID, an integer representing the ID of the book being borrowed. If the book is available and if the student is not currently borrowing 5 books, then the student is allowed to borrow the book. The ID of the student is saved into the record of the book (into the FCITbook object for the book). If this was the last available book, then the book availability is set to 'false' (to show all three of the books have been checked out). Additionally, the ID of the book must be saved into the array of currently borrowed books, booksBorrowed[], found within the FCITstudent object. You should save the ID of the borrowed book into the next available cell of the array. Meaning, if the student currently has 3 books borrowed, these three books will be saved at Index 0, Index 1, and Index 2 of the booksBorrowed[] array. The new book being borrowed should be saved into Index 3.

RETURNBOOK - This command is used for students returning a book. The command will be followed by the following information all on the same line: student ID, an integer representing the ID of the student returning the book. When a RETURNBOOK command is executed, the student will return the book that is stored in Index 0 of the booksBorrowed[] array. Therefore, even if a student has 5 books, the result of executing the RETURNBOOK command is that the student returns only one book, specifically, the book at Index 0. Note: after this book is "returned" to the system, the remaining books in the booksBorrowed[] array will need to SHIFT to the left. So if there were 3 books before the RETURNBOOK command, and these three books were in Index 0, Index 1, and Index2, after the command finishes, there should only be 2 books, in Index 0 and Index 1. Hint: after shifting, you will need to set the reference at Index 2 to point to null! Finally, when returning a book, you must remove that student's ID from the array of studentWhoHasBook[] inside the FCITbook object. And if all of the copies for that book were checked out, after the student returns one copy, that book should now be set to available, showing that at least one copy is available for borrowing.

DISPLAYBOOK - This command will be followed by an integer on the same line, representing the book ID you must search for and then display. Note, when processing this command, you must traverse the linked-list of books.

DISPLAYSTUDENT - This command will be followed by an integer on the same line, representing the student ID of the student to display. Note, when processing this command, you must traverse the linked-list of books.

DISPLAYALLBOOKS - This command will have nothing else on the same line. You must traverse the linked list of books and print all appropriate information.

DISPLAYALLSTUDENTS - This command will have nothing else on the same line. You must traverse the linked list of students and print all appropriate information.

DELETESTUDENT - This command will be followed by an integer on the same line, the student ID of the student who should be removed from the system. Note: before a student can be deleted, any and all currently borrowed books must be returned. Then, once all borrowed books are returned, the student can be removed from the system. To do this, you must invoke the delete method from the linked-list class, FCITstudentLL.

DELETEBOOK - This command will be followed by an integer on the same line, the ID of the book that should be removed from the system. Note: a book can only be deleted if NONE of the books, for that title, are checked out. So if no student has any of the books with this name, the book can be deleted. To do this, you must invoke the delete method from the linked-list class, FCITbookLL.

*See output for different printing possibilities.

To implement these commands, you should make many methods to help you. Here are some example methods:

void addBook(books, input, output);
void addStudent(students, input, output);
void displayBook(books, input, output);
void displayStudent(students, input, output);
void borrowBook(students, books, input, output);
void returnBook(students, books, input, output);
void deleteStudent(students, books, input, output);
void deleteBook(books, input, output);
int findBook(books, bookID);
int findStudent(students, studentID);

These methods can be in your main program, or they can be in any of your other classes. YOU are the programmer! The choice is up to you and your style for how you want to use these methods and where you want to use them. Also, you may want to use more methods to help you do certain tasks as needed in the program.

Output Format

Your program must output to a file, called "FCITlibrary2.out". You must follow the program specifications exactly. You will lose points for formatting errors and spelling.

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.