Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The ABC Book Company wants to implement a system to manage their books more efficiently. The system should allow both employees and patrons to checkout,

The ABC Book Company wants to implement a system to manage their books more efficiently. The system should allow both employees and patrons to checkout, find, and list books. A data file containing a sample list of books is provided. The data file contains a combination of four different types of books: childrens books, cookbooks, paperbacks, and periodicals. Each book is uniquely identified using an ISBN and the information for each type of book is described in the formatting section.

The ABC Book Company wants an interactive program that does the following:

  1. Checkout a book.
    • Allows a patron to checkout a book using its ISBN. If the book is unavailable, the user will be informed and the program will return back to the main menu. Otherwise, if the book is available, the available count will be decremented and the book information will be displayed.
  2. Find books by title.
    • Allows a patron to enter a search term and the program will display a list of books that have a title matching the search term.
  3. Display books of a specific type.
    • Allows a patron to view a list of books with a specific type. The user will also enter a format, diet, genre, or frequency (depending on the type of book) and the book list will be narrowed down further.
  4. Produce a list of random books.
    • Allows a patron to print a list of random books. The list of books can contain any type of book.

Formatting

Each type of book listed below is represented differently in the supplied books.txt file. Each line in the file represents a different book and each piece of information for a book is separated by a semi-colon.

Childrens Books

Childrens books have an ISBN, call number, available, total, title, author(s), and format. The last digit of the ISBN for a childrens book is 0 or 1. The format can either be Picture book, Early Readers, or Chapter book.

Each childrens book is represented in the books.txt file as follows: ISBN;Call number;Available;Total;Title;Authors;Format Example: 9782092530030;813.6;1;14;I Need a New Butt!;Dawn McMillan, Ross Kinnaird;E

Cookbooks

Cookbooks have an ISBN, call number, available, total, title, publisher, and diet. The last digit of the ISBN for a cookbook is either 2 or 3. The diet is either Diabetic, Vegetarian, Gluten-free, International, or None.

Each cookbook is represented in the books.txt file as follows: ISBN;Call number;Available;Total;Title;Publisher;Diet Example: 9787518397792;641.6 DOG;4;5;From Crook to Cook;Snoop Dogg;N

Paperbacks

Paperbacks have an ISBN, call number, available, total, title, author(s), year of release, and genre. The last digit of the ISBN for a paperback is between 4 and 7. The genre can either be Adventure, Drama, Education, Classic, Fantasy, or Science Fiction.

Each novel is represented in the books.txt file as follows: ISBN;Call number;Available;Total;Title;Authors;Year;Genre Example: 9782232375484;822.33 SHA;6;6;Hamlet;William Shakespeare;1602;C

Periodicals

Periodicals have an ISBN, call number, available, total, title, and frequency. The last digit of the ISBN for a periodical is either 8 or 9. The frequency can either be Daily, Weekly, Monthly, Bimonthly, and Quarterly. A periodical cannot be checked out.

Each periodical is represented in the books.txt file as follows: ISBN;Call number;Available;Total;Title;Frequency Example: 9782346146918;050;0;5;Dogster;B

Details

The ISBN or International Standard Book Number is a unique 13-digit number assigned to books. The last digit of the ISBN determines the specific type of book. Note that the maximum value for int is only 10 digits, therefore a bigger data type is required.

The call number is a sequence of characters (using the Dewey Decimal Formatting System) that patrons use to locate reading material. You are not required to validate the call number.

Given the formatting for the types of books:

  • Determine the attributes that are shared between the book types and create a Book class containing them. The Book class cannot be instantiated and must be a super-class.
  • Create the following classes where each one of them is to inherit the Book class and be located in the sait.bms.problemdomain package.
    • Cookbook
    • ChildrensBook
    • Paperback
    • Periodical
  • Each one of these classes is to have a user-defined constructor that assigns the appropriate attributes.
  • Override the toString() method in each one of these classes, so that the data is in a human readable form. The attributes should be displayed using vertical headers.

Along with the functionality mentioned above, you will need the following methods in your program:

  1. Implement a method that parses the supplied books.txt file into a single array list. The array list will be able to contain all Book types (cookbooks, childrens books, and paperbacks). Use the last digit of the ISBN to determine what a valid type of book needs to be created (see Formatting for more information).
  2. Implement a method that allows a patron to checkout a book. The user patron will be prompted to enter the ISBN of a book. If the entered ISBN does not match, the program will inform the patron with an error message. If the ISBN matches, the program checks the books availability. If there is a book available, the available count will be decremented and the books information will be displayed. Otherwise, the user patron will be informed the book is not available.
  3. Implement a method that prompts the user patron to enter a title, performs a case-insensitive search of books that containing the inputted title, and displays them.
  4. Implement a method that prompts the user for a type of book and displays all books of that type. Down-casting is required to determine the type of book is what the user specified.
  5. Implement a method that prompts a user to enter a number and the program displays that number of random books. The books can be any type. The Collections.shuffle method maybe used.
  6. Implement and call a method, when the program exits, that takes the books stored in the array list and persists them back to the books.txt file in the proper format.

Sample Runs:

An example of checkout books using ISBN (where input is shown in bold underline):

Welcome in ABC Book Company: How May We Assist You?

1 Checkout Book

2 Find Books by Title

3 Display Books by Type

4 Produce Random Book List

5 Save & Exit

Enter option: 1

Enter ISBN of book: 9787196778104

The book "The Hobbit" has been checked out.

It can be located using a call number: 823.9

An example of find books by title (where input is shown in bold underline):

Welcome in ABC Book Company: How May We Assist You?

1 Checkout Book

2 Find Books by Title

3 Display Books by Type

4 Produce Random Book List

5 Save & Exit

Enter option: 2

Enter title to search for: ham

Matching books:

ISBN: 9781784556280

Call Number: 813.54 SEU

Available: 3

Total: 14

Title: Green Eggs and Ham

Authors: Dr. Seuss

Format: Picture Book

ISBN: 9782232375484

Call Number: 822.33 SHA

Available: 6

Total: 6

Title: Hamlet

Authors: William Shakespeare

Year: 1602

Genre: Classic

An example of display books by type (where input is shown in bold underline):

Welcome in ABC Book Company: How May We Assist You?

1 Checkout Book

2 Find Books by Title

3 Display Books by Type

4 Produce Random Book List

5 Save & Exit

Enter option: 3

# Type

1 Children's Books

2 Cookbooks

3 Paperbacks

4 Periodicals

Enter type of book: 4

Enter a frequency (D for Daily, W for Weekly, M for Monthly, B for Biweekly, or Q for Quarterly): B

Matching books:

ISBN: 9794025081038

Call Number: 050

Available: 0

Total: 5

Title: MAD

Frequency: Bi-monthly

ISBN: 9782346146918

Call Number: 050

Available: 0

Total: 5

Title: Dogster

Frequency: Bi-monthly

An example of produce random book list (where input is shown in bold underline):

Welcome in ABC Book Company: How May We Assist You?

1 Checkout Book

2 Find Books by Title

3 Display Books by Type

4 Produce Random Book List

5 Save & Exit

Enter option: 4

Enter number of books: 1

Random books:

ISBN: 9780957220737

Call Number: 823.914 MIL

Available: 0

Total: 10

Title: Death of a Salesman

Authors: Arthur Miller

Year: 1949

Genre: Drama

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

600 lb 20 0.5 ft 30 30 5 ft

Answered: 1 week ago