question archive CSE 214 – Data Structures Homework 3 – Spring 2022 Homework 3 – due Thursday, April 17 2022, no later than 11:59 PM EST Problem 1: New Library Imagine you’re a software developer for a new library that needs to digitize its book keeping

CSE 214 – Data Structures Homework 3 – Spring 2022 Homework 3 – due Thursday, April 17 2022, no later than 11:59 PM EST Problem 1: New Library Imagine you’re a software developer for a new library that needs to digitize its book keeping

Subject:Computer SciencePrice:28.99 Bought3

CSE 214 – Data Structures
Homework 3 – Spring 2022
Homework 3 – due Thursday, April 17 2022, no later than 11:59 PM EST
Problem 1: New Library
Imagine you’re a software developer for a new library that needs to digitize its book keeping. Every day,
library card holders attempt to check out and turn in their favorite books. This new library has a collection
of Books stored in an internal repository we’ll refer to as BookRepository.
BookRepository is composed of 10 endless shelves, one for each digit 0-9, represented using Linked
Lists. Books are placed on each shelf depending on the first digit of their unique 13-digit ISBN number
(everything else about the book need not be unique). Within each shelf, books are sorted
lexicographically/numerically in ascending order by some criteria including:
• ISBN (13-Digit number and default at start of your program)
• Name
• Author
• Genre
• Year
• Condition (New, Good, Bad, Replace)
The library also has an external stack of returned books, which we’ll refer to as ReturnStack. Library
card holders with a 10-digit userID return their books and submit a ReturnLog of their return into
ReturnStack; these books can later be marked as checked in. Keep in mind that books might be returned
late (returned after their due date), which means a librarian might want to check them in as soon as
possible (and clean out the stack while they’re at it).
Write a program which will be responsible for managing both BookRepository and ReturnStack. For
BookRepository, your program will be responsible for the following:
• Adding a new book to BookRepository
• Removing a book from BookRepository
• Checking in a book within BookRepository
• Checking out a book within BookRepository
• Re-arranging specific shelves by some criteria
For ReturnStack, you will be responsible for the following:
• Logging returned books
• Checking in the book of the last return log
• Emptying out and checking in the stack when a book is turned in late
By default, all books start as checked in. A valid ISBN must be less than 13 digits. A valid userID must be
less than 10 digits. Any ISBN less than 13 digits must be padded with leading 0s when displayed.
YOU CANNOT USE:
• Collections.Sort() or any other built in JAVA sorting classes or methods
• ArrayList
Compilation and Submission:
On Blackboard, be sure to submit a SINGLE .zip file (NOT .rar, .7z, etc.) named
your_studentID#_HW3.zip
When decompressed, your zip file should contain only your assignment’s .java files in a single folder
labeled HW3.
Your program must run on its own and should not crash. Use exception handling as required. If your
program does not compile, you will receive a 0 for it. You have to write all the CODE BY YOURSELF.
Any form of plagiarism will result in 0 in the homework and possibly even a Q for the course.
NOTE: Although your program may run well on your Integrated Development Environment (IDE) of
choice (i.e. Eclipse, Visual Studio, InteliJ, etc.), your program WILL NOT be compiled or graded using
any IDE. Instead, your program will be compiled on a standard Unix shell in the same directory as your
decompressed HW3 folder using the following 2 commands:
javac *.java
java LibraryManager
Ensure that your program compiles with these two commands into a usable state. If you have any
questions contact any of the TAs and/or attend office hours.
Required Classes and More:
The following classes are required for this problem. Each class provides a description and the
specifications necessary to complete its implementation. If you feel that additional methods or
variables would be useful, feel free to add them during your implementation as you see fit.
However, all the variables and methods in the following specifications must be included in your
homework. You should declare the data fields of the classes as private and should provide the
public getter and setter methods where reasonable or required. Alongside these required classes, you will
have to define enum variables used within these class definitions.
Additionally, “fully documented classes” are classes which have enough reasonable comments and
documentation for TAs and the professor to understand your implementation of this assignment. There is
no strict criteria, but at minimum you must include comments that describe crucial steps of computation
within your implementation.
1. Date [10 points]
Write a fully documented class named Date that contains that contains the day, month, and year of
a point in time. Also implement the compare() method, which should allow you to compare two
dates with regards to chronological order using Java’s comparison operators.
• public Date() constructor and also public Date(…parameters as needed…)
• Three int variables:
o day
o month
o year
• public static int compare(x, y) - returns 0 if x = y, -1 if x < y, and 1 if x > y
• Getters and setters for all members.
2. Book (Linked List Node) [10 points]
Write a fully documented class named Book that contains parameters of the information about
itself. The Book class should contain variables for the book!s name, author, year of publication,
genre, condition, and ISBN Number. In addition, it should also contain variables on whether it has
been checked out, who checked it out, and its return date.
• public Book() constructor and also public Book(…parameters as needed…)
• Three String variables:
o name
o author
o genre
• One (enum) Condition:
o bookCondition
o Two long variables
o ISBN
o checkOutUserID
• One int variables:
o yearPublished
• One Date variable
o dueDate
• One Book variable
o nextBook
• One Boolean
o checkedOut
3. Shelf (Linked List) [20 points]
Write a fully documented class named Shelf that contains books in a particular shelf of
BookRepository. The Shelf class should contain a Book reference to the start of your shelf and its
length. Also implement the toString() method, which should print all of the shelve!s data in tabular
form.
• public Shelf() constructor
• Two Book variables
o headBook
o tailBook
• One int variable:
o length
• One (enum) SortCriteria variable
o shelfSortCriteria
• public void addBook(Book addedBook)
o Brief:
" Adds a book to the shelf while maintaining that shelf’s current sorting
criteria.
o Parameters:
" addedBook – book to be added.
o Preconditions
" None.
o Postconditions
" The book is added to the list in ascending order.
o Returns
" None.
o Throws
" BookAlreadyExistsException: A book with the same ISBN already exists.
• public void removeBook(long removedISBN)
o Brief:
" Removes the book with the name bookName from the shelf.
o Parameters:
" removedISBN– the ISBN Number of.
o Preconditions
" Shelf is not empty.
o Postconditions
" The book with the same name is removed from the shelf.
o Returns
" None.
o Throws
" InvalidISBNException: Thrown if checked out book’s ISBN is invalid.
" BookDoesNotExistException: A book with the same ISBN does not exist.
• public void sort((enum) SortCriteria sortCriteria)
o Brief:
" Sorts books on shelf in lexicographical/numeric order given some sorting
criteria in ascending order.
o Parameters:
" sortingCriteria– criteria to sort by.
o Preconditions
" None.
o Postconditions
" Shelf is sorted using parameter criteria.
o Returns
" None.
o Throws
" None.
4. BookRepository [20 points]
Write a fully documented class named BookRepository that contains all shelves and is able to add,
remove, check in, and check out Books. The BookRepository class should have a fixed-length array
of 10 shelves.
• Public BookRepository() constructor
• One Shelf Array
o shelves[10]
• public void checkInBook(long checkedInISBN)
o Brief:
" Checks in book with the ISBN checkedInISBN from BookRepository.
o Parameters:
" long checkedInISBN – The ISBN of the book to be checked in.
o Preconditions
" A book with the same name exists in BookRepository.
o Postconditions
" The book with the same name is checked into BookRepository.
o Returns
" None.
o Throws
" None.
• public void checkOutBook(long checkedOutISBN, long checkOutUserID, Date dueDate)
o Brief:
" Checks out book with the ISBN checkedOutISBN from BookRepository.
o Parameters:
" long checkedOutISBN – The ISBN of the book to be checked out.
" long checkOutUserID – The ID number of the person checking out this book.
" Date dueDate – The date the book must be returned by.
o Preconditions
" A book with the same name exists in BookRepository.
o Postconditions
" The book with the same name is checked out from BookRepository.
o Returns
" None.
o Throws
" InvalidISBNException: Thrown if checked out book’s ISBN is invalid.
" InvalidUserIDException: Thrown if the person’s userID is invalid.
" BookAlreadyCheckedOutException: Thrown if a book has already been
checked out.
• public void addBook(long addISBN, String addName, String addAuthor, String addGenre, String
addYear, (enum) Condition addCondition)
o Brief:
" Adds a book to BookRepository on the correct shelf.
o Parameters:
" long addISBN – The ISBN of the book to be added.
" String addName – The name of the book to be added.
" String addAuthor – The author of the book to be added.
" String addGenre – The genre of the book to be added.
" String addYear – The genre of the book to be added.
" (enum) Condition addCondition – The condition of the book to be added.
o Preconditions
" None.
o Postconditions
" The book is added to the correct shelf based off the first digit of the book’s
ISBN.
o Returns
" None.
o Throws
? InvalidISBNException: Thrown if added book’s ISBN is invalid.
? BookAlreadyExistsException: Thrown if a book with the same ISBN already
exists in BookRepository.
• public void removeBook(long removeISBN)
o Brief:
" Removes a book by name from BookRepository.
o Parameters:
" long removeISBN – Name of book to be removed.
o Preconditions
" Book exists in BookRepository.
o Postconditions
" The book is removed from BookRepository.
o Returns
" None.
o Throws
? InvalidISBNException: Thrown if removed book’s ISBN is invalid.
• public void sortShelf(int shelfInd, String sortCriteria)
o Brief:
" Sorts a specific shelf by some criteria.
o Parameters:
" int shelfInd - index of shelf to be sorted
" String sortCriteria - criteria to sort shelf by
o Preconditions
" None.
o Postconditions
" Shelf at shelfInd is sorted using sortCriteria’s corresponding enum.
o Returns
" None.
o Throws
? InvalidSortCriteraException: Thrown if sortCriteria has no corresponding
enum.
?
5. ReturnLog [10 points]
Write a fully documented class named ReturnLog that allows us to track which books have been
returned to the library.
• public ReturnLog() constructor and also public ReturnLog(…parameters as needed…)
• Two long variables:
o ISBN
o userID
• One Date variable:
o returnDate
• One ReturnLog variable:
o nextLog
• Getters and setters for all members.
6. ReturnStack [20 points]
Write a fully documented class named ReturnStack that allows us to take in returns (push) and
check in the last returned book (pop). ReturnStack should implement the toString() method, which
should print all of the ReturnStack!s data in tabular form.
• Public ReturnStack() constructor
• One ReturnLog variable
o topLog
• public bool pushLog(long returnISBN, String returnUserID, Date returnDate, BookRepository
bookRepoRef)
o Brief:
" Pushes a returned book’s ReturnLog into the stack.
o Parameters:
" long returnISBN – The ISBN of the book that was returned.
" long returnUserID – The ID number of the person returning this book.
" Date returnDate – The date the book was actually returned.
" BookRepository bookRepoRef – A reference to your BookRepository used to
verify the information of the return.
o Preconditions
" None.
o Postconditions
" A ReturnLog of the returned book is added to the top of ReturnStack.
o Returns
" Whether the returned book was late or on-time.
o Throws
" InvalidISBNException: Thrown if the returned book’s ISBN is invalid.
" InvalidReturnDateException: Thrown if the return date is invalid.
" BookNotCheckedOutException: Thrown if a book with this ISBN is not
checked out.
" BookCheckedOutBySomeoneElseException: Thrown if a book was originally
checked out by someone else.
" InvalidUserIDException: Thrown if userID is invalid.
• public ReturnLog popLog()
o Brief:
" Pops the last returned book’s ReturnLog from the top of ReturnStack.
o Parameters:
" None.
o Preconditions
" ReturnStack should be non-empty.
o Postconditions
" ReturnStack should have had its top log removed.
o Returns
" None.
o Throws
" EmptyStackException: Thrown if ReturnStack is empty.
7. LibraryManager: [10 points]
Write a fully documented class named LibraryManager. This class will allow the user to interact
with the Stack in order to manipulate them.
• Must contain your main method
o public static void main (String [] args)
• One BookRepository variable
o BookRepository
• One ReturnStack variable
o ReturnStack
• This method should implement the following menu options:
" (B) – Manage Book Repository
• (C) – Checkout Book
• (N) – Add New Book
• (R) – Remove Book
• (P) – Print Repository
• (S) – Sort Shelf:
o (I) – ISBN Number
o (N) – Name
o (A) – Author
o (G) – Genre
o (Y) – Year
o (C) – Condition
" (R) – Manage Return Stack
• (R) – Return Book
• (S) – See Last Return
• (C) – Check In Last Return
• (P) Print Return Stack
" (Q) – Quit
Sample Input / Output
// Comment in green, input in red, output in black
Example: Adding a Book
Starting...
Menu:
(B) – Manage Book Repository
(C) – Checkout Book
(N) – Add New Book
(R) – Remove Book
(P) – Print Repository
(S) – Sort Shelf
(I) – ISBN Number
(N) – Name
(A) – Author
(G) – Genre
(Y) – Year
(C) – Condition
(R) – Manage Return Stack
(R) – Return Book
(L) – See Last Return
(C) – Check In Last Return
(P) – Print Return Stack
(Q) – Quit
Please select what to manage: B
Please select an option: N
Please provide an ISBN number: 1234567891011
Please provide a name: How to Tell If Your Cat Is Plotting to Kill You
Please provide an author: Matthew Inman
Please provide a genre: Humor
Please provide a publishing year: 2008
Please provide a condition: New
Loading...
How to Tell If Your Cat Is Plotting to Kill You has been successfully added to the book repository!
Example: Removing a Book
Menu:
(B) – Manage Book Repository
(C) – Checkout Book
(N) – Add New Book
(R) – Remove Book
(P) – Print Repository
(S) – Sort Shelf
(I) – ISBN Number
(N) – Name
(A) – Author
(G) – Genre
(Y) – Year
(C) – Condition
(R) – Manage Return Stack
(R) – Return Book
(L) – See Last Return
(C) – Check In Last Return
(P) – Print Return Stack
(Q) – Quit
Please select what to manage: B
Please select an option: R
Please provide an ISBN Number: 1234567891011
Loading...
How to Tell If Your Cat Is Plotting to Kill You has been successfully removed from the book repository!
Example: Checking Out a Book
Menu:
(B) – Manage Book Repository
(C) – Checkout Book
(N) – Add New Book
(R) – Remove Book
(P) – Print Repository
(S) – Sort Shelf
(I) – ISBN Number
(N) – Name
(A) – Author
(G) – Genre
(Y) – Year
(C) – Condition
(R) – Manage Return Stack
(R) – Return Book
(L) – See Last Return
(C) – Check In Last Return
(P) – Print Return Stack
(Q) – Quit
Please select what to manage: B
Please select an option: C
Please provide a library user ID: 6269239014
Please provide an ISBN Number: 1234567891011
Please provide a due date: 07/28/1998
Loading...
How to Tell If Your Cat Is Plotting to Kill You has been checked out by 6269239014 and must be returned
by 07/28/1998
Example: Printing the Book Repository
Menu:
(B) – Manage Book Repository
(C) – Checkout Book
(N) – Add New Book
(R) – Remove Book
(P) – Print Repository
(S) – Sort Shelf
(I) – ISBN Number
(N) – Name
(A) – Author
(G) – Genre
(Y) – Year
(C) – Condition
(R) – Manage Return Stack
(R) – Return Book
(L) – See Last Return
(C) – Check In Last Return
(P) – Print Return Stack
(Q) – Quit
Please select what to manage: B
Please select an option: P
Please select a shelf: 0
Loading…
Name Checked Out Due Date Checkout UserID
==================================================================================================
==
Harry Potter and the

Sorcerer’s Stone
Twilight
Y
N
05/21/2022
N/A
6328883491
N/A


// Have this table look like your table from HW1/HW2. The first column must be what sorting criteria
we’re using (ISBN, Name, Author, Genre, or Condition).
Example: Sorting a Shelf
Menu:
(B) – Manage Book Repository
(C) – Checkout Book
(N) – Add New Book
(R) – Remove Book
(P) – Print Repository
(S) – Sort Shelf
(I) – ISBN Number
(N) – Name
(A) – Author
(G) – Genre
(Y) – Year
(C) – Condition
(R) – Manage Return Stack
(R) – Return Book
(L) – See Last Return
(C) – Check In Last Return
(P) – Print Return Stack
(Q) – Quit
Please select what to manage: B
Please select an option: S
Please select a shelf: 0
Please select a sorting criteria: G
Loading...
Shelf 0 has been sorted by genre!
Example: Returning a Book
Menu:
(B) – Manage Book Repository
(C) – Checkout Book
(N) – Add New Book
(R) – Remove Book
(P) – Print Repository
(S) – Sort Shelf
(I) – ISBN Number
(N) – Name
(A) – Author
(G) – Genre
(Y) – Year
(C) – Condition
(R) – Manage Return Stack
(R) – Return Book
(L) – See Last Return
(C) – Check In Last Return
(P) – Print Return Stack
(Q) – Quit
Please select what to manage: R
Please select an option: R
Please provide the ISBN of the book you’re returning: 1234567891011
Please your Library UserID: 6269239014
Please your current date: 07/27/1998
Loading...
// You should be able to print out the book’s name with the ISBN alone
How to Tell If Your Cat Is Plotting to Kill You has been returned on time!
Example: Returning a Book Late
Menu:
(B) – Manage Book Repository
(C) – Checkout Book
(N) – Add New Book
(R) – Remove Book
(P) – Print Repository
(S) – Sort Shelf
(I) – ISBN Number
(N) – Name
(A) – Author
(G) – Genre
(Y) – Year
(C) – Condition
(R) – Manage Return Stack
(R) – Return Book
(L) – See Last Return
(C) – Check In Last Return
(P) – Print Return Stack
(Q) – Quit
Please select what to manage: R
Please select an option: R
Please provide the ISBN of the book you’re returning: 1234567891011
Please your Library UserID: 6269239014
Please your current date: 07/29/1998
Loading...
// Your return stack should have all its book checked in after this
How to Tell If Your Cat Is Plotting to Kill You has been returned LATE! Checking everything in…
Example: Seeing the Last Returned Book
Menu:
(B) – Manage Book Repository
(C) – Checkout Book
(N) – Add New Book
(R) – Remove Book
(P) – Print Repository
(S) – Sort Shelf
(I) – ISBN Number
(N) – Name
(A) – Author
(G) – Genre
(Y) – Year
(C) – Condition
(R) – Manage Return Stack
(R) – Return Book
(L) – See Last Return
(C) – Check In Last Return
(P) – Print Return Stack
(Q) – Quit
Please select what to manage: R
Please select an option: L
Loading...
Among Us Pro Guide 2022 is the next book to be checked in.
Example: Checking in the last return
Menu:
(B) – Manage Book Repository
(C) – Checkout Book
(N) – Add New Book
(R) – Remove Book
(P) – Print Repository
(S) – Sort Shelf
(I) – ISBN Number
(N) – Name
(A) – Author
(G) – Genre
(Y) – Year
(C) – Condition
(R) – Manage Return Stack
(R) – Return Book
(L) – See Last Return
(C) – Check In Last Return
(P) – Print Return Stack
(Q) – Quit
Please select what to manage: R
Please select an option: C
Loading...
// Your book repository should reflect this book being checked in
Among Us Pro Guide 2022 has been checked in!
Example: Printing the return stack
Menu:
(B) – Manage Book Repository
(C) – Checkout Book
(N) – Add New Book
(R) – Remove Book
(P) – Print Repository
(S) – Sort Shelf
(I) – ISBN Number
(N) – Name
(A) – Author
(G) – Genre
(Y) – Year
(C) – Condition
(R) – Manage Return Stack
(R) – Return Book
(L) – See Last Return
(C) – Check In Last Return
(P) – Print Return Stack
(Q) – Quit
Please select what to manage: R
Please select an option: P
Loading...
// Your table should reflect the order of your stack

ISBN UserID Return Date
==================================================================================================
==
8765535522
05/21/2022
1234567891011

2938888883330 9882227734 08/21/2022

Option 1

Low Cost Option
Download this past answer in few clicks

28.99 USD

PURCHASE SOLUTION

Option 2

Custom new solution created by our subject matter experts

GET A QUOTE

rated 5 stars

Purchased 3 times

Completion Status 100%