This program should be completed on repl.it
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 borrowing 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 broken down by section. Please refer to the walkthrough from lecture and the grading rubric 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. Library catalog Your library 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 library 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 library 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 library. 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 library 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 library 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 error checking for invalid input. How to submit your code When you are done with your code, click into your browser’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 rubric 200 points total. Now that we are in an elective class, the grading rubric will look different than in 205. You will be graded on your program matching the following criteria. Each letter corresponds 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 rubric. 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 Error code H covers multiple test conditions with seeing available books, checking out a book, and returning a book. I -10: any other error with checking out or returning a book Admin view J -15: the entire library 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 errors not listed above, I’ll grade them based on whether they have a small (-5), medium (-10), or large (-15+) impact 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 errors 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.