Reference no: EM132192989
Write an application that simulates adding new books to the Amazon database.
The Application repeatedly asks the information of a new book and once the information is gathered, it will be displayed to the user. Note that this application does not save the information of the book.
Information of the book includes its title, author, the number of ratings, the sum of all the rating (the rating given to a book is 1 or 2 or 3 or 4), its price and whether the book has a hardcover or not.
When adding a new book, the user can choose to provide only the book title and its author. The rest of the information will be set to default values by the program: Price to random number between 1 and 10, the number of ratings and the sum of ratings to 0 and no hardcover for the book.
The user can also choose to enter all the book's information.
A book can have 0 or more than one rating. Rating given to a book is a number between 1 (lowest) and 4 (highest). The number of ratings and the total will be saved in the book's information.
After information is entered for the book, it will be displayed to the user. The program will also display a recommendation information for the book based on its average rating: If the average rating is between 3 and 4, the book is strongly recommended, between 2 and 3 is recommended, between 1 and 2, not recommended and if there is no rating then no information is available for recommendation.
Specifications & Requirements
Design and implement a Java application to satisfy the specified high level requirements from the Overview section. The system is required to do the following:
Data Element Class - Book
Create a class with the given information (fields) in the overview section.
Create a constructor that takes book's title and author and creates a book instance with the provided information. The number of ratings, Total rating will be set to zero, price is set to random number between 1 and 10 and the book has not hardcover.
Create another constructor that takes the information for the title, author, price and whether the book has hardcover or not and creates a book instance with the given information. The number of ratings, Total rating will be set to zero.
A method addRating that takes the rating for the book and adds it to the total rating as well as incrementing the number of ratings for this book.
A method called findAvgRating that returns the average rating for this book or 0 if there is no rating for the book.
A method called bookRecommendation that returns a string based on the average rating of the book. The book is "strongly recommended" for average rating between 3 and 4, "Recommended" for average rating between 2 and 3(exclusive) , "Not Recommended" for average rating between 1 and 2 (exclusive) , and if there is no rating return "No Information Is Available For Recommendation".
A toString method that returns the string representation of a Book object: title, author, number of ratings, average rating, price and book recommendation.
Add any necessary getter or setter methods.
Driver Class - Amazon
This is the driver class for Book that contains a main method.
Create a method getInput() that returns a Book object. This method allows the user to enter book information, uses the information to construct a Book object and returns it.
This class contains a main method which continues asking the book information as long as user chooses to enter more information and displays the information of the book to the user. Refer to the program sample run for more clarification.
Add any necessary methods to modularize your code.