Tags:
tag this topic
create new tag
view all tags
---+ Methods 2: Inventory control with files: Spring 2024 ---++ Learning Objective(s) 1 Improving methods skill 1 Work with files 1 Use constants ---++ Overview of the Program Create a program to inform the user if a certain item needs to be reordered because of low levels ---++ Specifics * The program should be called *Reorder* * There should be three constants for the file names: names.txt, onhand.txt, minamount.txt * The program should continue to read in items (as strings) from the user until the word "quit" is entered * for each item, it should tell the user if more should be re-ordered and if so, how many. * The only I/O allowed in the main method should be to get the name of each item (along with the associated prompt) * You should have one method that will process a single item. It should not directly read from any file but call other methods that read from a file * You should have a method that is sent an item and a file name. It should return the line number that item is on. If that item is not in the file, or it is a bad file, it should return -1 * You should have another method that is sent a line number and a file name and it should return that number at that line in the file. If there is a problem with the file, it should either return -1 or exit the entire program. * If a method opens a file, it should close it before it returns ---++Sample dialogue Below is a sample dialogue. Your output can vary somewhat as long as the required data is nicely displayed <pre> <b>What item do you want to check on (quit to exit)?</b> apple <b>Please order at least 4 of apple.</b> <b>What item do you want to check on (quit to exit)?</b> basket <b>There is no need to reorder basket.</b> <b>What item do you want to check on (quit to exit)?</b> banana <b>There is no need to reorder banana.</b> <b>What item do you want to check on (quit to exit)?</b> quit </pre> You can also run a solution for this program if you want. See classroom instructions for more details. ---++Submission a. Create your SDR. * In *Lessons Learned*, include a discussion on how many things could go wrong. You only need to test for two * 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 a. Convert your SDR into a pdf document a. Create an empty zip folder a. Place your java file and pdf document in it. a. Submit the zip folder on canvas ---++Hints 1 [[CSC121S2024Lab06Hint0][Steps to develop]] 1 [[CSC121F2023Lab06Hint1][Algorithm hint]] 1 [[CSC121F2023Lab06Hint2][Finding the item]] 1 [[CSC121F2023Lab06Hint3][Finding a number in a file]] 1 [[CSC121F2023Lab06Hint4][Constants]] ---++ 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. * Don't throw the IOExceptions but catch them instead
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2024-02-14
-
CathyBareiss
Home
Site map
Assessment web
BethelAIResources2026 web
CenterForComputing web
ChatGPT web
Intro2AIatBethel web
Main web
Sandbox web
TWiki web
CenterForComputing Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback