Inventory updates: Improvement with arrays: Spring 2024

06 Mar 2024 - 15:05 | Version 1 |

Learning Objective(s)

  1. Learn about arrays and how to use arrays
  2. Do more abstraction

Overview of the Program

Adapt the previous program to use arrays so that each file needs only be read once and the inventory written out only upon ending the program

Specifics

  • The program should be called Inventory. I recommend making a copy in a different folder!
  • 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
  • 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. There is one more that you need.
  • You should have one method that will process a single command.
  • You may only read each file one time. I recommend loading the items, current inventory, and control levels into arrays at the start of the program
  • You may only write the inventory to a file once at the end of the program. Write a method to do this
  • All arrays should allow for unused space
  • You may assume that there is never more than 1000 items in the inventory
  • One method that displays the status of an item would be helpful.
  • A method to load a file into an integer array that returns the number of data values read would be helpful
  • A method to load a file into a string array that returns the number of data values read would be helpful
  • 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.
  • 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 comparing your previous program to this one. How did using arrays impact the result.
    • 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 for the changes
  2. Loading a file
  3. Arguments to your methods

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