Answered step by step
Verified Expert Solution
Link Copied!

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 0 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 =4.22f;
System.out.printf("Price: %.2f", 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: 2018
Do you want to enter the sell price? (yes|no): no
Enter quantity: 10
Enter choice: print
Enter search to print books with title or enter all to print all: all
Inventory Number: 0 Quantity: 10
Title: Java in a Nutshell
Author: Griffith
Year Published: 2018
Price: 0.00
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: 2005
Do you want to enter the sell price? (yes|no): yes
Enter price: 14.99
Enter quantity: 1
Enter choice: add
Enter title: Code
Enter author: Pretzold
Enter year published: 1999
Do you want to enter the sell price? (yes|no): yes
Enter price: 9.99
Enter quantity: 1
Enter choice: add
Enter title: Coding for 240
Enter author: You
Enter year published: 2005
Do you want to enter the sell price? (yes|no): no
Enter quantity: 20
Enter choice: print
Enter search to print books with title or enter all to print all: all
Inventory Number: 0 Quantity: 1
Title: Design of Everyday Things
Author: Norman
Year Published: 2005
Price: 14.99
Inventory Number: 1 Quantity: 1
Title: Code
Author: Pretzold
Year Published: 1999
Price: 9.99
Inventory Number: 2 Quantity: 20
Title: Coding for 240
Author: You
Year Published: 2005
Price: 0.00
Enter choice: print
Enter search to print books with title or enter all to print all: Cod
Inventory Number: 1 Quantity: 1
Title: Code
Author: Pretzold
Year Published: 1999
Price: 9.99
Inventory Number: 2 Quantity: 20
Title: Coding for 240
Author: You
Year Published

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

Students also viewed these Databases questions