Answered step by step
Verified Expert Solution
Question
1 Approved Answer
imagine we are designing a system that will allow an owner of a bookstore The Book Worm, to add books to their inventory so they
imagine we are designing a system that will allow an owner of a bookstore "The Book Worm", to add books to their inventory so they can keep tracks of what books they currently have in the store.
For the books, we will want to store the title, author, and year published. You should define a class to hold these properties and create a constructor so that an object can only be created if it has all of these properties.
There is also an optional field that we can add to the book which is the sell price if it is known at the time. You should create an additional constructor to allow creating the book with the sell price. You should also use the appropriate constructor based on the input from the user.
All properties of the book should be private but you should have a get method getter for each property.
Once a book is created, it should be added to an "Inventory" object. An inventory object should contain the book that was created, the quantity, and an inventory number that you create. You should create a constructor that takes in all of these properties. The inventory number should start at and increment after each inventory object is created. The properties of the inventory object should be private but we should have a get method for each property.
Lastly, there should be a Database class that allows you to add an inventory object. For the Database class, you will want to override the default constructor so that you can initialize an ArrayList to hold all of the inventory objects. Your Database class should have the methods that allow an inventory object to be added and allow it to be removed based on the inventory number. Additionally, you should add a method to the class that prints what inventory items exist. You should overload the print method to optionally pass in a "search term" which would print titles that contain that search term.
In the Main class, you will want to prompt the user for four options. One option is to add a book which will then allow them to create a book object and then an inventory object. Another will be to print inventory items which will ask them if they want to print all inventory items or print those that contain part of a title. Finally, they can remove an inventory item by providing an inventory number. The Main class should run until the user types in done which is the fourth option.
It is highly encouraged that you work with a partner on this assignment. Before you start writing the code for this assignment, you should focus on what properties and methods are required and design the classes, properties, and methods you need. Pay close attention to the formatting provided below when you submit your assignment. If you do not match the formatting example below, you will lose points on this assignment.
Tip: If you need to print out a float with two decimal places, below is an example:
float price f;
System.out.printfPrice: f price;
Example Interaction
Just adding a book and printing:
Welcome to the Book Worm
What would you like to do
add print remove done
Enter choice: add
Enter title: Java in a Nutshell
Enter author: Griffith
Enter year published:
Do you want to enter the sell price? yesno: no
Enter quantity:
Enter choice: print
Enter search to print books with title or enter all to print all: all
Inventory Number: Quantity:
Title: Java in a Nutshell
Author: Griffith
Year Published:
Price:
Enter choice: done
Add, add, add, print, print with filter, remove, print, done
Welcome to the Book Worm
What would you like to do
add print remove done
Enter choice: add
Enter title: Design of Everyday Things
Enter author: Norman
Enter year published:
Do you want to enter the sell price? yesno: yes
Enter price:
Enter quantity:
Enter choice: add
Enter title: Code
Enter author: Pretzold
Enter year published:
Do you want to enter the sell price? yesno: yes
Enter price:
Enter quantity:
Enter choice: add
Enter title: Coding for
Enter author: You
Enter year published:
Do you want to enter the sell price? yesno: no
Enter quantity:
Enter choice: print
Enter search to print books with title or enter all to print all: all
Inventory Number: Quantity:
Title: Design of Everyday Things
Author: Norman
Year Published:
Price:
Inventory Number: Quantity:
Title: Code
Author: Pretzold
Year Published:
Price:
Inventory Number: Quantity:
Title: Coding for
Author: You
Year Published:
Price:
Enter choice: print
Enter search to print books with title or enter all to print all: Cod
Inventory Number: Quantity:
Title: Code
Author: Pretzold
Year Published:
Price:
Inventory Number: Quantity:
Title: Coding for
Author: You
Year Published
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