November 28, 2018 / Book Class / Due: ______
Purpose
The purpose of this assignment is to get experience with Arrays and enumerated types. The project involves the creation of a Book class along with a driver that demonstrates the functionality of the Book class.
Category
Set up an enumerated type called Category that represents the following types of books: Fiction, Biography, History, SelfHelp, Reference, and Other.
BookType
Set up an enumerated type calledBookType that represent the following types of publications: Paperback, Hardback, Electronic, and Other
Book Class
Create a Book class with at least the following attributes:
- A String representing the title of the book
- An array of 5 Strings to hold the names of up to 5 authors/co-authors
- An integer between 0 and 5 that tells how many authors the book has
- A double representing the price of the book
- A Category representing the Category in which the book falls
- A BookType representing the type of publication
The Book class should have a default constructor, a copy constructor, and a parameterized constructor that allows the user to pass values for the attributes as parameters.
The Book class should have getters and setters (public or private) as appropriate for each of its attributes. Give thought to whether the outside world should be able to “see” and/or “change” the attribute values, and define the getters/setters accordingly.
The Book class should provide a toString method that formats all information about a Book for possible display by the driver. The price should be formatted as currency (dollars and cents). The exact format is up to you, but it should be easy to understand for a user of the program.
Driver Class
The driver class should be menu-driven. The main menu should ask whether the user wishes to create a book, display the most recent book, or quit. If the user asks to display a book before one is created, display an error message.
If the user chooses to create a Book, the driver should prompt for the appropriate information, and then instantiate a Book object.
The driver should display a welcome message at the beginning of the program and a goodbye message when the user chooses to quit.
Do not put all driver code in one big main method. Instead, each method in the driver should have one focused task such as gathering information for creating a book, displaying a welcome message, displaying a goodbye message and so forth. The main method should be primarily a series of calls to these “helper” methods.
All input and output should be done from the driver class. The driver should validate the user input. For example, the title of a Book may not be missing. The price of a book must be greater than zero. A book may have no authors specified (for example, a dictionary typically has no list of authors).
Make the program user-friendly and all output neatly formatted and easily understood. You have flexibility in deciding exactly how this should look. You should consider using JOptionPane dialogs for some part of the project to get experience with these dialogs.
Menu Class
You may create a Menu class to handle creating a menu, displaying a menu, inputting the user’s selection, verifying that the user’s selection is valid, and so forth. On the website, there is posted a util.zip file that contains two .java files and a Word document. One of the two .java files is a Menu class and the Word document explains how to use it. You are not required to use this Menu class or to create your own for this assignment, but you may if you wish.
Your driver may use as many menus as you wish. For example, the driver may display a menu of book Category values for the user to select the appropriate category for a book and a similar menu of publication types.
Submission and Due Dates
Within one week, turn in your initial design document (see the course web site for an example). Follow the instructions in the Course Facts posted on the web site for naming and submitting the design materials.
The final project including all .java files and an updated design document is due in two weeks. Follow the instructions in the Course Facts for naming the file and for determining its contents.
Sample Output from One Solution
The figure below shows a portion of the output produced during one run of an example solution for this assignment. You are not required to make your output identical to this output, but your output should be as easy to read and understand as this sample, and it should contain similar content.
The sample is provided to give you some ideas and to help guide your design process.
Page 1