Electronic Inventory Records Management (EIRM)
In this individual assignment, you will create a Java software package to manage the shop inventory records according to the given instructions/commands.
1. Your software must:
Read and validate the contents of TWO input files (including inventory file and instruction file), and
Process the inventory records in the inventory file according to the instructions in the instruction file. The instructions should be performed sequentially (i.e. one after the other).
When your program ends, your software saves the resulting inventory list (after being processed)
to TWO output files (that are the file containing the processed inventory list, and the report file).
2. Your software must be executed using command line in the following format:
java EIRM14S2/EIRM inventoryfile instructionfile outputfile reportfile
EIRM14S2 is the package containing your assignment software.
EIRM is the name for the main class.
inventoryfile – is a command line argument specifying the full path and name of an input file containing the list of product items.
instructionfile – is a command line argument specifying the full path and name of an input file containing the set of operations to be carried out by your software.
outputfile – is a command line argument specifying the full path and name of an output file where the resulting records to be saved by your software.
reportfile – is a command line argument specifying the full path and name of a file where the output of query commands will be stored.
DO NOT implement a graphical user interface (GUI). DO NOT hard code the names of the command line arguments as they will change between runs of the program. Some example invocations using the Command Prompt:
java EIRM14S2/EIRM Z:\rec\[url removed, login to view] Y:\[url removed, login to view] X:\out\[url removed, login to view] W:\[url removed, login to view] java EIRM14S2/EIRM C:\rec007\[url removed, login to view] D:\[url removed, login to view] E:\[url removed, login to view] U:\[url removed, login to view]
FORMAT AND DESCRIPTION OF INPUT INVENTORY DATA
1. Your software needs to read in the valid inventory records in the product file.
When your EIRM system starts up, it assumes that the shop has the products as given in the inventory file, and it manages the shop inventory according to the instructions in the instruction file.
2. An input inventory record has necessary information of a product item. Each record consists of multiple fields to specify the product name, prices, quantity, and dates etc.
The fields include: “product” (name of the product), “quantity” (in stock quantity), “boughton” (date of purchase) / soldon (date of sale), “boughtat” (price of purchase) / soldat (price of sale), “useby” (best-before date).
Single/Multiple spaces and/or Tab characters separate the name of the field and the value/content of the field.
The “product” and “quantity” fields are MANDATORY for EVERY record. All other fields are optional.
Each field begins on a new line; the name of the field is the first word on this line. However, the value for some fields may spread across multiple lines.
Fields may occur in any order
3. Description of Fields
product: is a string to specify the name of a product.
quantity: is a numeric value to specify the in stock quantity of a product.
boughton, useby, soldon: are the dates in the format of “(d)d-(m)m-(yy)yy”. Example: 11-07-
2014 or 2-2-14.
boughtat, soldat: are the price of purchase/sale of a product. Starts with a dollar sign “$” and followed by a numeric value.
Example: "[url removed, login to view]" is a sample file containing product records, as below:
product sugar boughton 13-5-2014 useby 12-12-2014 boughtat $[url removed, login to view] quantity 100
product sauce pan quantity 10 boughtat $[url removed, login to view] boughton 13-5-2014
4. The input inventory file contains zero or multiple inventory records in a predefined format.
Records are separated by blank line(s).
If there is an error in the format of the “product” or “quantity” fields, the entire record is discarded and not read. If the error occurs for any other field, only the erroneous field is omitted.
FORMAT AND DESCRIPTION OF INSTRUCTIONS
1. Your software needs to read in and parse the valid commands in instruction file.
2. The instruction file contains zero or more instructions to be performed on product items.
Each instruction occurs on a new line.
There are five possible instructions: “buy”, “sell”, “discard”, “sort”, and “query”.
Each instruction begins with one of the five instructions followed by a list of parameters.
3. Description of instructions
buy a certain quantity of product(s) and add all the product(s) into the stock. The instruction “buy” is followed by the fields and their corresponding values. Fields are separated by semicolons and single/ multiple spaces (“; ”) and may occur in any order.
o The command MUST contain values for the “name” and “quantity” fields.
o For instance, the instruction
buy product milk; boughton 31-3-2014; useby 5-4-2014;
boughtat $[url removed, login to view]; quantity 100
means: on 31/3/2014, 100 bottles of milk with a use-by date of 5/4/2014, at a price
of $[url removed, login to view] were bought.
sell a certain quantity of a specific type of product(s)
o For instance, the instruction
sell product coffee; soldon 4-4-2014; soldat $[url removed, login to view];
indicates: 1 tin of coffee was sold on 4/4/2014 at the price of $[url removed, login to view] and the stock and
retail information need to be updated correspondingly. The command would be ignored if no sufficient available stocks; and we do not sell expired product(s). NOTE: The ESM system assumes that, for each type of product, the product items with the earliest “use-by” date would be sold first.
sort the records in ascending order based on the value of a field. The command “sort”
followed by the name of a field.
o Your program MUST implement a sorting algorithm and MUST NOT invoke any sorting function from the Java API.
indicates: sort all the product in ascending order of “use-by” dates.
discard the expired product item(s) For instance, the instruction discard 5-3-2014
indicates: discard all the product items that would be expired on 5/3/2014. Each
product is supposed to be expired on the next day of its use-by date. The stock information need to be updated correspondingly.
query certain information from the collection based on field values. There are THREE formats for this instruction.
(1) Format 1: query the available inventory on a given date. For instance, the instruction
1) a list of available product items in stock on this date (eg 8/5/2014), with information of product name, quantity and use-by date. The query results should be displayed in ascending order of use-by date.
2) the suggestions on purchasing products if the quantity of the available products is less than 10.
(2) Format 2: query the best or worst sales during a given period of time. The instruction “query” followed by the word “bestsales” or “worstsales” and two dates. For instance, the instruction
query bestsales 01-06-2014 30-6-2014
query worstsales 01-06-2014 30-6-2014
reports the bestsales (or worstsales) products during the sale period from 1/6/2014 to
30/6/2014. The bestsales (or worstsales) are determined according to the return on assets (ROA)  for each type of product. Products with highest (or lowest) ROA are considered the bestsales (or worstsales). The formula for ROA is:
ROA Net Income
Quantitybegin Quantityend / 2
where Net Income is defined as the difference between net sales and purchasing cost, and Quantitybegin and Quantityend are the product quantities at the beginning and the end of the sale period respectively.
(3) Format 3: query the profit gained during a given period. The command “query”
followed by the word “profit” and two dates. For instance, the instruction
query profit 3-3-2014 2-4-2014
1) the net income gained during the given period (eg from 3/3/2014 to 2/4/2014);
2) the loss due to discarding the out-of-date items, and list the discarded items in descending order of costs.
FORMATE OF OUTPUT FILES
1. Your software needs to save the resulting data collection to files including output file and report file.
a. Save the resulting data collection of the instructions of “buy”, “sell”, and “discard” into an output file.
b. Save the query results to a separate report file. When there are more than one “query” command, append the new query results to the end of the report file. The results of different queries should be separated by a line with three dashes (“---“).
2. The output files should have all the necessary resulting records.
3. Each field should fit on ONE line only
4. Records should be separated by blank line(s)
5. Report File: the results of different queries should be separated by a line with three dashes (“---”).
1. Your code must make use of at least one collection e.g. ArrayList.
2. Your system must be able to handle both normal cases and difficult cases.
3. You MUST NOT build a graphic user interface.
4. You need to do systematic testing of the classes you create.