Inventory updates: Methods, files and command line arguments: Fall 2023

22 Jun 2023 - 13:26 | Version 1 |

Learning Objective(s)

  1. Learn to use command line arguments
  2. Do more abstraction
  3. See the need for a way to store a group of data in memory

Overview of the Program

Create a program the queries and updates inventory status. There is to be a file with the commands:
  • = means to display the item, how much is currently in stock and the level at which to reorder
  • + means to record the arrival of more inventory of a given item
  • - means to remove a certain amount for the inventory of a given item
  • ! means to quit the program

Specifics

  • The program should be called Inventory
  • There is to be no use of System.in in the final version.
  • All error messages are to go System.err
  • The only output to go to System.out should be the status of any given item specified with the = command.
  • All file IOExceptions should be caught (not thrown)
  • The file data will be coming from files specified at the command line. Samples of each file can be found in the lab folder. The order of the files is as follows:
    1. The list of items in the inventory
    2. The amount currently in stock of each item
    3. The reorder level of each item
    4. The list of commands to be processed
    5. The temp file used when saving the results
  • There should be at least 9 constants. 5 for the position of each filename in the command line and 4 for each type of command
  • You should have one method that will process a single command.
  • A method to copy one file of integers (unchanged) to another file would be helpful.
  • A method to copy one file of integers (changing the integer on one specific line by adding another integer to it) to another file would be helpful.
  • One method that displays the status of an item would be helpful.
  • A method to retrieve an integer on a specific line in a file would be helpful (returning 0 on problems).
  • A method to return the line an item appears in a file would be helpful (returning -1 on problems)
  • The file that contains the commands is to be opened and closed only once and those tasks are to be done in the main method.
  • The opening and closing of any of the four files can only be done in a total of four different methods. (Suggestion: finding the location of an item, getting the n'th number in a file, copying a file (unchanged), and copying a file (changing one number)
  • if a method opens a file, it should close it before it returns

Sample dialogue

The only output would be when displaying the status. You can see that output if you run the program in the lab folder See classroom instructions for more details.

Submission

  1. Create your SDR.
    • In Lessons Learned, include a discussion the level of abstraction (i.e. how generic each of your methods is). The fewer methods that explicitly reference the task (inventory control) the better (as long as it is achieved while still having quality variable and method names).
    • Your testing should include at least 2 different types of errors and ensure that every line of code is executed at least once. Add copies of your files that you used (with appropriate links back to the test cases) at the end of the report. Try to put them in columns to save space. You might want to have different sets of files for some of the different tests.
    • If you used any hints, be sure to indicate that in the Outside Resources Used section
    • For Future Improvements include a discussion about what tasks would the program need to accomplish to make this a complete inventory control system
  2. Convert your SDR into a pdf document
  3. Create an empty zip folder
  4. Place your java file and pdf document in it.
  5. Submit the zip folder on canvas

Hints

  1. Algorithm hint to process a command
  2. Hint to output to a file
  3. Hint to copy a file (with and without changing
  4. Abstraction hint

Optional improvements

Optional improvements should ONLY be worked on once the program is completing working. In addition, the work is to be done on your own with little if any help for lab assistants or the instructor.
  • Also have the program create another file (on command) with the list of items to be reordered based on current inventory levels
  • Adapt the files so that the list of items, inventory level and control level are all in one file.
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback
This website is using cookies. More info. That's Fine