You are creating a simple library where people can check out and check in books. In the
Fantastic news! We've Found the answer you've been seeking!
Question:
You are creating a simple library where people can check out and check in books. In the future, the library plans to expand its collection beyond just books, so we will be creating an object model that provides the ability to expand at a later date. Implement the following classes and choose the most appropriate data type for each variable:
- Have a class named Media, which cannot be instantiated
- You need to be able to store: title, sub-title, number of copies, id number, and heldBy (this is a list of who has checked it out at the moment).
- You need an abstract method named "checkOut" that takes a String variable "name" as a parameter and returns a boolean.
- You need an abstract method named "checkIn" that takes a String variable "name" as a parameter and returns a boolean.
- Have a class named Book that inherits from Media, which can be instantiated
- You need to be able to store who the author of the book is in addition to the inherited fields.
- Provide an implementation of checkOut, which should print "Checking out [title of book], by [author of book]" and return true if there are copies of the book available (hint: compare the number of copies with the length of the heldBy list).
- Provide an implementation of checkIn, which should print "[name] checking in [title of book]" and return true if that person had actually checked it out, then it should remove them from the heldBy array list
- Make a main function in the App class
- Create 2 books, have 3 copies for the first book and 1 copy for the second book
- Call checkout on the first book with name = "Mark Twain"
- Call checkout on the first book with name = "Charles Dickens"
- Ensure that both of these return true (you can simply print the result)
- Call checkin on the first book with name = "Mark Twain"
- Call checkin on the first book with name = "Samuel Clemens"
- Ensure that the first result is true and the second is false
- Call checkout on the second book with name = "Mark Twain"
- Call checkout on the second book with name = "Charles Dickens"
- Ensure that the first result is true and the second is false
- Call checkin on the second book with name = "Mark Twain"
- Call checkout on the second book with name = "Charles Dickens"
- Ensure that both of these return true
Related Book For
Accounting Information Systems
ISBN: 978-0133428537
13th edition
Authors: Marshall B. Romney, Paul J. Steinbart
Posted Date: