must all be coded in java you ve been hired by half foods to write a java console ap 5152658
MUST ALL BE CODED IN JAVA
You’ve been hired by Half Foods to write a Java console application that manages product inventory. The application has the following two classes:
Product.java
This class represents one product in their inventory and includes:
● Fields
– (static) productCount – count of all distinct products; initialize to 0 in declaration.
– (static) inventoryValue – total inventory value of all products; initialize to 0 in declaration.
– (static) inventoryCount – total count of all products in inventory; initialize to 0 in declaration.
* code
* name
* cost
* count
● A constructor with no parameters that sets the fields, respectively, to these values:
productCount = productCount + 1
code = -1
name = “(not set)”
cost = -1
count = -1
● A constructor with four parameters that sets the fields, respectively, to these values:
productCount = productCount + 1
inventoryValue = inventoryValue + (cost * count)
inventoryCount = inventoryCount + count
code – set from parameter
name – set from parameter
cost – set from parameter
count – set from parameter
● Getter methods for each field (declare the getters for productCount, inventoryValue, and inventoryCount static).
● Setter methods for each field (declare the setters for productCount, inventoryValue, and inventoryCount static).
● equals method that compares codes from two objects for equality.
● toString method for returning instance variable values only.
HW5.java
This class contains the main method and uses the other class to manage Product data. Create text file ProductInventoryIn.txt, paste the following data into it, and place the file in your project folder. It has the following columns:
1) Product code
2) Product name
3) Product cost
4) Product quantity
ProductInventoryIn.txt
70 Gourmet Popcorn 2.80 50
71 Veggie Burgers 5.00 60
72 Italian Bread 4.00 70
73 Electrolyte Water 2.20 80
74 Shaved Parmesan 8.00 90
75 Lemonade 1.50 40
76 High Protein Bars 1.30 30
77 Ginger Shampoo 7.50 20
78 Blueberry Toothpaste 3.00 10
79 Goodnight Candles 2.50 100
Read the data from file ProductInventoryIn.txt into an array of Product objects called products. Present the following menu to the user:
Half Foods Menu
1 – Sell product
2 – Order product
3 – List product inventory
4 – Exit
Enter an option:
Here are what the options do:
● Sell product – use a validation loop to prompt for and get from the user the code of the product to be sold (it has to be a valid code). Then use a validation loop to prompt for and get from the user the quantity of the product to be sold. Insure that the quantity is not greater than the current inventory for that product. Update the following fields:
– (static) inventoryValue
– (static) inventoryCount
* count for the product
Print a message in formatted columns including:
* Code
* Quantity
* Revenue from sale
● Order Product – use a validation loop to prompt for and get from the user the code of the product to be ordered (it has to be a valid code). Then use a validation loop to prompt for and get from the user the quantity of the product to be ordered. Insure that the quantity is greater than zero. Update the following fields:
* (static) inventoryValue
* (static) inventoryCount
* count for the product
Print a message in formatted columns including:
* Code
* Quantity ordered
* Cost of order
● List product inventory shows all product data in formatted columns. It then lists the product count, inventory value, and inventory count.
● Exit closes the menu.
Continue to process menu options until the user enter 4. Then write the data to file ProductInventoryOut.txt*** in the same layout as the input file. Use these menu options and inputs for your last run:
Option Code Quantity
3
1 70 10
3
2 71 40
3
1 72 20
3
2 73 25
3
1 10,74 100,10
3
4
Hint: declare a keyboard object as a field (global) and close it at the end of method main.