Write the Java code to simulate an inventory control system and a point of sale system with customer history.
On program start, each inventory item's data is read from the inventory file, placed in a new item class object, which is then placed in the inventory ArrayList. The ArrayList should be a field in the purchasing class (see below). The inventory data consists of the following fields. Only the last three data fields (as listed here) should be modifiable after the object is created. A constructor will accept parameters for each of the fields.
(a)The item's name
(b)The item's cost
(c)The current quantity of the item on-hand
(d)The number of times the item has been purchased
(e)The number of times the item has been returned.
After the inventory is processed, each existing customer's data is read from the customer file, placed in a new item class object, which is then placed into the customer ArrayList. The ArrayList should be a local variable in the main method. The customer data consists of the following fields. All data in the customer class should be modifiable based on the details given later. A constructor will accept parameters for each of the fields.
(a)The customer's name
(a)The customer's balance (positive balance indicates the customer has funds available to spend, and negative balance indicates the customer owes money)
(c)The customer's purchase history populated by a list of inventory item references from the inventory ArrayList. The history is stored in the customer file as a list of inventory names along with the number of purchased items.
(d)The customer's shopping cart, initially empty and not stored in the customer file, but also populated by a list of inventory item references.
A purchasing class object contains the following methods for manipulating the inventory ArrayList and a passed customer object. Each method will update the listed properties. A default constructor will create an instance of the inventory ArrayList and the value for a restocking fee.
(a)Add an item to shopping cart (inventory: quantity; customer: shopping cart)
i.The customer is presented with a list of available items and makes one selection. The menu of items shown to the user is generated from the ArrayList of inventory items.
ii.As long as there is at least one of items on-hand, the item selected is placed in the customer's cart ArrayList and the quantity on-hand is decreased in the inventory ArrayList.
iii.The customer may instead choose to not select an item to place in the cart.
(b)Remove item from shopping cart (inventory: quantity, customer shopping cart)
i.The customer is presented with the contents of their shopping cart.
ii.The item selected is removed from the customer's cart ArrayList and the quantity on-hand is increased in the inventory ArrayList.
iii.The customer may instead choose to keep the contents of the cart.
(c)Purchase items in a shopping cart (inventory: purchase count; customer: balance, purchase history, shopping cart)
i.Print to the terminal) a receipt listing the cart items. This includes the name and cost of each item, plus the total cost of all items. If there are no items in the cart, a receipt is not printed.
ii.Increase the purchase count of the items in the inventory ArrayList
iii.Deduct the shopping cart total from the customer's balance
iv.Add the items to the customer's purchase history
v.Empty the shopping cart ArrayList
vi.Replace the data in the inventory file with the data currently in the inventory ArrayList (i.e., the inventory file is updated so that it is correct)
vii.Replace the data in the customer file with the data currently in the customer ArrayList (i.e., the customer file is updated so that it is correct)
(d)Return an item with a restocking fee (inventory: quantity, return count; customer: balance, purchase history)
i.Print (to the terminal) a listing of the purchase history. This includes the name and cost of each item. If there are no items in the purchase history, a listing is not printed.
ii.Increase the return count of the selected item in the inventory ArrayList.
iii.Add the cost of the returned item to the customer's balance minus a restocking fee.
iv.Remove the returned item from the customer's purchase history
v.Replace the data in the inventory file with the data currently in the inventory ArrayList.
vi.Replace the data in the customer file with the data currently in the customer ArrayList (i.e., the customer file is updated so that it is correct)
4. In the main method, the user is presented with a prompt asking for their name. Either a new customer entry is created or the customer from the ArrayList with the matching name is selected. The user is then presented with a menu of items based on the list of methods in the purchasing class. All methods are represented in the menu. When the customer leaves, the next customer can elect to shop or halt the program.
User input is indicated as red text.
Enter your name: Bob
Hello Bob, your current balance is $-12.00 and your shopping cart is empty.
Would you like to:
(a) Add an item to the shopping cart
(b) Remove an item from the shopping cart
(c) Purchase items in shopping cart
(d) Return an item
Enter an option (x to leave): a
The inventory list is:
(1) item 1 ($2.00, 5 available)
(2) item 2 ($4.00, 5 available)
(3) item 3 ($8.00, 15 available]
(4) item 4 ($16.00, 15 available)
Enter an item (0 to cancel): 2
Would you like to:
(a) Add an item to the shopping cart
(b) Remove an item from the shopping cart
(c) Purchase items in shopping cart
(d) Return an item
Enter an option (x to leave): a
The inventory list is:
(1) item 1 [$2.00, 5 available]
(2) item 2 [$4.00, 4 available)
(3) item 3 [$8.00, 15 available]
(4) item 4 ($16.00, 15 available)
Enter an item (0 to cancel): 0
Would you like to:
(a) Add an item to the shopping cart
(b) Remove an item from the shopping cart
(c) Purchase items in shopping cart
(d) Return an item
Enter an option (x to leave): b
Current shopping cart contents:
(1) item 2
Enter an item (0 to cancel): 0
Would you like to:
(a) Add an item to the shopping cart
(b) Remove an item from the shopping cart
(c) Purchase items in shopping cart
(d) Return an item
Enter an option (x to leave): c
Thank you for your purchase.0
Receipt: item 2 [$4.00]
Your current balance is $-16.00
Would you like to:
(a) Add an item to the shopping cart
(b) Remove an item from the shopping cart
(c) Purchase items in shopping cart
(d) Return an item
Enter an option (x to leave): d
There will be a $1.50 restocking fee
The purchasing history is:
(1) item 1 [$2.00]
(2) item 3 ($8.00)
(3) item 1 [$2.00)
(4) item 2 [54.00]
Enter an item (0 to quit): 4
The item has been returned.
Your current balance is 5-13.50
Would you like to:
(a) Add an item to the shopping cart
(b) Remove an item from the shopping cart
(c) Purchase items in shopping cart
(d) Return an item
Enter an option (x to leave): x
Select C to continue or Q to quit: Q
The files below would be generated after the above example completed execution.
Inventory File
item 1
2.0
5
2
0
item 2
4.0
5
1
1
item 3
8.0
15
1
0
item 4
16.0
15
0
0
Customer File
Bob
-13.5
3
item 1
item 3
item 1
Carol
0.0
0
Dan
-2.0
1
Item 1
Create an administrative menu to perform the following operations. Each should be implemented as separate methods in the purchasing class.
1.Calculate the most purchased item overall
2.Calculate the most returned item overall
3.Order items that are low in the inventory based on a threshold
4.Determine the customer with the lowest balance (i.e., owes the most money)