What to do: Create a project consisting of three classes. These three classes are named ProgTwo.java, Product.java and ProductCollection.java. You must have these three classes and they must work as it is described in these specifications. You are welcome to add methods to any class that you may find useful. You must add comments to all your classes, using the javadoc style commenting modeled in class. You may add other classes if you consider them necessary.
This assignment requires you to implement at least three classes. The first class, Product, models a basic Product object for record keeping of the product's data on a daily basis. The second class ProductCollection, implements methods for storing and maintaining a single dimension array of Product objects. The third class ProgTwo has a main method which creates and manipulates Product objects and stores/retrieves the Products from an array structure.
Your program must be developed following the guidelines previously discussed in class. These guidelines include appropriate variable names, use of comments to describe the purpose of the program and the purpose of each method, and proper use of indentation of all program statements.
One Constructor
Constructor #1. It will take all the parameters as listed:
int idNum
String name
double price
int quantity
Instance variables for the Product class
int idNum
String name
double price
int quantity
Methods that must be part of the Product class (you may and probably will add other methods):
One Constructor which has no parameters.
Instance variables for the ProductCollection class
Product[] collection
int count
Methods that must be part of the ProductCollection class (you may add other methods):
ProgTwo should manage a array of product objects. Initial data about products is available in a text file named product.txt. This should be read into the array of products. The product.txt file is delimited by commas. After the array is created a loop is entered. The loop should display a menu which has the following options, obtain the number of the type of transaction from the user, and process the transaction. The loop should continue to execute until the "8" Exit option is selected from the menu. When the exit option is selected, the program should write out to a text file information about all the products in the array in the same format as the input file. The name of the output text file should be productUpdate.txt.
1. Add Product Prompt the user to enter the data required for a new product and add the product into the array of products.
2. Delete Product Have the user enter the product ID. If the product exists, prompt the user to confirm that they want the product to be deleted. If so, delete the product by moving all of the products below it in the array up one compartment and subtract one from count. Display an informative message to the user regarding the action taken.
3. Change Price Have the user enter the product ID and the new price of the product. Change the price of the product in the array if it exists, otherwise display an informative message to the user that the product does not exist.
4. Purchase Product Units Have the user enter the product ID and quantity of the product purchased. Adjust the quantity to reflect the purchase of products. Display a message for the user if the product does not exist in the array.
5. Sell Product Units Have the user enter the product ID and quantity of the product to be sold. Adjust the quantity to reflect the sale of products. Display a message for the user if the product does not exist in the array.
6. Display information about an individual product Have the user enter the ID number of the product to be displayed. Display the information if the product exists, otherwise display an information message.
7. Display information about all the products List all the products in inventory by using the toString( ) method.
8. Exit This will end the program execution.