I tried to use array(or vector) to put each information that I read from certain textfile, in this case the file is named "items_Mon.txt," via BufferedReader. I actually could read the file itself, however, I am unable to put the information into small potion by array. If you have any suggestions, I will be happy.
Assignment Scenario
You work for a small grocer, who knows you have been taking computer programming courses. The owner would like to take more control over the store’s inventory and ordering process and has asked you to write a program to help with some tasks:
1) Current Inventory Report – shows all items, cost, price, and quantity on-hand
2) Customer Price List – shows all items and their retail prices
3) Re-order report – what he needs to place on the next order
The owner goes around the store and makes a hand-written list of currently inventory every day. The file is typed it in to a computer as a text file, and emailed to you for processing. There are sometimes mistakes in the file (duplicate entries and incomplete entries).
Requirements
Your program should read the file, and note any errors. It may stop if there are incomplete entries, but should post an error message for the invalid line. If a duplicate entry is found (matching description and each fields), post an error message, do not add the duplicate entry, and continue to process the file. Generate the three reports to the console, per the examples.
Add the three (incomplete) java source files and copy the three ‘items_Day’ files provided to your project from the csdata/CMPSC22/Fall06/Final folder:
1) GroceryList.java - “Driver” with main method
2) Item.java - Class to represent a single grocery item
3) ItemLinkedList.java - Class to implement a linked list of Items
Example Output for Monday List:
Enter the name of the store:
Don's Mighty Mart
Enter items file name:
items_Mon.txt
Adding new item 1: Green Beans
Adding new item 2: Kernel Corn
Adding new item 3: Farm Fresh Eggs
Adding new item 4: Whole Milk
Adding new item 5: Skim Milk
Adding new item 6: Organic Milk
Adding new item 7: Wheat Bread
Adding new item 8: White Bread
Adding new item 9: Swiss Cheese
Adding new item 10: Sharp Cheddar Cheese
Adding new item 11: Mild Cheddar Cheese
Adding new item 12: Sliced Ham
Adding new item 13: Lean Ground Beef
Adding new item 14: Ground Beef
Adding new item 15: Tortilla Chips
Adding new item 16: Potato Chips
Adding new item 17: Butter
Adding new item 18: Peanut Butter
Adding new item 19: Berry Jelly
Adding new item 20: Grape Jelly
Adding new item 21: Romaine Lettuce
Adding new item 22: Iceberg Lettuce
Adding new item 23: Carrots
Adding new item 24: Onions
Adding new item 25: Potatoes
NullPointerException:
at java.util.StringTokenizer.<init>(Unknown Source)
at java.util.StringTokenizer.<init>(Unknown Source)
at GroceryList.main(GroceryList.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
>
public static void main(String args[])
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter the name of your shop");
String shopName = keyboard.nextLine();