Question
Java Programming Can I please get help with this assignment. Please see assignment details below. A BookStore has-a Product (Book, Magazine, etc), so when we
Java Programming
Can I please get help with this assignment. Please see assignment details below.
A BookStore has-a Product (Book, Magazine, etc), so when we store products in the book store class, that's an example of composition.
A book is-a type of product, so when we create subclasses Book and Magazine, we're using inheritance.
Your methods will work on the baseclass type Product instead of on Book or Magazine (with the exception of Book-specific methods). For example in searchProductsByTitle(), your code works without knowing if a Product is specifically a Book or Magazine, and this is an example of polymorphism.
The BookStore class will contain a product database using a data structure called HashMap (also known as a hash, or associative array, or dictionary). The HashMap will map Strings (ISBN numbers) to Product objects so it will be a HashMap
The BookStore class will implement some specific behaviors that we'll specify in three interfaces, which will define our API:
IStore:
* has one method public void add(Product p) to add a product to the hashmap
ISortableStore:
* will have three methods that all return a List
ISearchableStore:
* will have two methods that return a List
To implement the various sorts, create several Comparator classes which you can use with Collections.sort() -- we will review in class. Comparator is an interface that you will use on your sort classes. It is a little more flexible that Comparable which we already looked at in class.
Your Product class will contain constructors, getters and setters, and private data (ISBN (String), title (String), price (double)). Your Book subclass will extend Product and override its constructor (while still calling the parent constructor), toString(), and will add data and getter/setter for author. Magazine will not add any new data or behavior and will just exist to illustrate variety of products.
In your main method please create several books and magazines and add them using the add() method, and show examples of all method defined in the 2 other interfaces (e.g. searches and sorts).
Example output (yours may differ but should be as complete):
--- sort all by title --- Vonnegut, Catfish 22, 5.0, 23423423-234234 John Doe, Doe's Memoir, 25.0, 123445-2123124 Mr. Rogers, My Neighborhood, 15.0, 45322-4345235 Science Weekly, 4.0, 314314314-31414 --- sort all by price --- Science Weekly, 4.0, 314314314-31414 Vonnegut, Catfish 22, 5.0, 23423423-234234 Mr. Rogers, My Neighborhood, 15.0, 45322-4345235 John Doe, Doe's Memoir, 25.0, 123445-2123124 --- sort books by author --- John Doe, Doe's Memoir, 25.0, 123445-2123124 Mr. Rogers, My Neighborhood, 15.0, 45322-4345235 Vonnegut, Catfish 22, 5.0, 23423423-234234 --- search all by title --- Mr. Rogers, My Neighborhood, 15.0, 45322-4345235 --- search books by author --- John Doe, Doe's Memoir, 25.0, 123445-2123124
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started