Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Project 2: Library What is a library? In case you haven’t been to a library in a while, a library is a place that has a large collection of books. You can “check out” a book, meaning that you’re...

1 answer below »

Project 2: Li
ary
What is a li
ary?
In case you haven’t been to a li
ary in a while, a li
ary is a place that has a large collection of books. You can “check out” a book, meaning that you’re bo
owing it for a few days. When you’re done reading it, you can “return” it. If you don’t return the book by the due date, your book becomes “overdue.” When you return the overdue book, typically you have to pay a late fee.
What your JS program should do
Since this is a complex prompt, you won’t see instructions numbered individually. Instead, the instructions are
oken down by section. Please refer to the walkthrough from lecture and the grading ru
ic to check that you have covered everything.
Main menu
Start your program by displaying a main menu. The user can choose from the following actions, all described below:
1. See available books
2. Check out a book
3. Return a book
4. Admin view
5. Simulation
6. Quit
After each valid action, return the user to the main menu.
“Quit” should end the program gracefully.
Please make it clear to the user how each option is accessed (e.g., first letter or via number). You can assume the user will type a valid entry.
Li
ary catalog
Your li
ary should have at least ten books. While you are creating and testing your program, you can create fake books like “T1” by A1, which means the title is T1 and the author is A1. Then you’ll have “T2” by A2, etc.
Once you’re done with your program, you can go back and change the books to real titles and authors if you wish.
I recommend also giving each book an identifier like a number or short letter code. This will help with testing your program and during grading.
Store these books into an appropriate data structure(s) of your choice.
Properties of a book
By default, a book is listed as “available” to check out.
When a user checks out a book, mark the book as “checked out” and include the user’s name.
If a checked out book is overdue, mark it as “overdue” and include the user’s name.
When a book is returned, mark it as “available” again.
Action item: 1. See available books
When a user chooses this option, show them a list of all available books including title and author, and the identifier if you have one. These are books that are marked as “available.” The first time you run the program, this should be all books. After the first time, it can but may not be all books.
Return the user to the main menu.
Action item: 2. Check out a book
When a user chooses this option, ask them first for the book identifier or title (however you are identifying unique books). Next, ask them for their name.
In your li
ary catalog data structure, mark the book as “checked out” and include / associate the book with the user’s name.
You can assume the user will type a valid entry.
Return the user to the main menu.
Action item: 3. Return a book
When a user chooses this option, ask them for the book identifier or title (however you are identifying unique books).
In your li
ary catalog data structure, mark the book as “available” and remove the user’s name.
You can assume the user will type a valid entry.
Return the user to the main menu.
Action item: 4. Admin view
When a user chooses this option, show them a list of all books and their status.
If a book is available, show the book details and the status “available.”
If a book is checked out, show the book details, the status “checked out”, and the user’s name who has the book.
If a book is overdue, show the book details, the status “overdue”, and the user’s name who has the book.
Return the user to the main menu.
Action item: 5. Simulation
When a user chooses this option, your program should simulate one day of action in a li
ary. First, please display a simple confirmation message to let the user know the simulation is starting.
Cheat sheet: flipping a coin in JS (first section)
I will use TRUE and FALSE below. TRUE means 1 or heads. FALSE means 0 or tails.
For each book in the catalog, flip a coin and proceed with the appropriate action below:
· If a book is available and the coin is TRUE, mark the book as “checked out” and choose a random name from a list as the user. You can make a list of friends’ names or use the list from P1: Rich, Sabine, Tamra, Kyle. Cheat sheet: random number in JS. Display a message saying this book has been checked out by [random name].
· If a book is available and the coin is FALSE, do nothing.
· If a book is checked out and the coin is TRUE, mark it as “overdue.” Display this information in a message.
· If a book is checked out and the coin is FALSE, “return the book” and mark it as “available.” Follow the same “return the book” actions. Display a confirmation message that this book has been returned.
· If a book is overdue and the coin is TRUE, generate (alert) a message to the user using the user’s name. It can be as simple as “Hello [name], your book is overdue.” If you want to get fancy with it, you can include book details, but this is not required.
· If a book is overdue and the coin is FALSE, “return the book” and mark it as “available.” Follow the same “return the book” actions. Display a confirmation message that this book has been returned.
Once the simulation is done, you can show a simple message letting the user know. All of the changes will be made on the back end (hidden to the user) in your li
ary catalog so the user doesn’t need to see any output except for the overdue and confirmation messages. Return the user to the main menu.
Assumptions, hints, and clarifications
· It is possible that an overdue book stays overdue for multiple simulations. This is ok. Just keep generating a message each time.
· Hint: one way to think about the catalog logic is that each book has attributes like title and status. When a book is checked out, you change the status. There should also be a collection or group of books that make up the li
ary catalog so you can access each one during the simulation. Find, or create, a data structure that allows for this.
· You can assume all entries will be valid. You do not need to do any e
or checking for invalid input.
How to submit your code
When you are done with your code, click into your
owser’s address bar and copy that entire link. This is shown in the screenshot below.
Go to the assignment submission area in Canvas. Paste your link and submit.
Grading ru
ic
200 points total.
Now that we are in an elective class, the grading ru
ic will look different than in 205. You will be graded on your program matching the following criteria. Each letter co
esponds to a “test case.” The number after the letter is the point deduction if your program is not able to meet that test case. You will see these letters on your grading feedback, which you can then match back to this ru
ic.
Main menu and quit
Not graded.
See available books; Check out a book; Return a book
H -20: books that are checked out or overdue still show up in the available list OR books that are available or returned do not show up in the available list
E
or code H covers multiple test conditions with seeing available books, checking out a book, and returning a book.
I -10: any other e
or with checking out or returning a book
Admin view
J -15: the entire li
ary catalog is not shown
K -20: each book is not shown with its title and author, status, and the user’s name if checked out or overdue
Simulation
After I check the action items above, I will reload your program and run your simulation multiple times. At some point in the simulation due to probability, a book will be checked out, or a book will be marked overdue, or a book will be returned. I will confirm these actions by viewing available books.
L -20: it does not seem that your simulation works (if I think this is the case, I will keep running it to be sure)
Misc
For other e
ors not listed above, I’ll grade them based on whether they have a small (-5), medium (-10), or large XXXXXXXXXXimpact on the program.
If you can’t finish the whole program, add a submission comment on Canvas and let me know what works and what doesn’t work. Try to get your program to run without e
ors so I can at least try the parts that work. You can still earn partial credit for the parts that don’t work.
Hopefully nobody submits a blank file, but blank files will earn a 0.
Answered 1 days After Mar 15, 2022

Solution

Sanchi answered on Mar 16 2022
100 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here