The Rules 1. You MUST use the default package in your assignment so that we can...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The Rules 1. You MUST use the default package in your assignment so that we can compile and run your program easily. 2. ALL data members MUST be declared as private (or protected in the Base class when necessary only). 3. Your program must be written using Object Oriented Principles (as outlined in the course notes and previous courses) and with efficiency in mind, you may lose marks for inefficient code. 4. Never leave compile warnings, address them without suppressing them! 5. A solution that does not compile will receive a grade of 0. Problem Description In this assignment, you will modify the solution to Assignment 1. You are to start with your solution to Assignment 1. You must also submit a test plan for the functionality created in this assignment. You must add to your test plan from assignment 1 to include testing the new functionality and addressing any feedback you have received. All requirements must still behave the same as described in assignment 1 unless overwritten by the requirements here. Requirements 1. Friendly Input: Ensure that your solution accepts spaces in any string input. Efficiency: You will update the inventory data structure in two ways: 2. o Change the inventory declaration in the Inventory class to be an object of ArrayList. Change the insert into the data structure so that the FoodItem objects are in numerical order from smallest to largest by itemCode in the most efficient way possible. Once the inventory structure is sorted, modify your other methods to also make them as efficient as possible. (Note - do NOT use Generic Collection methods yet - we will learn to do the coding ourselves first). 3. Saving data: You will add two menu selections to your assignment: O O Do NOT use the built-in binarysearch method - use your own custom-made binary search method. Hint: you can modify and reuse the binary search method you wrote in the earlier labs). You are allowed to use any built-in methods of the ArrayList collection. The first will read the contents of a file and add them to the Inventory::inventory ArrayList. (i.e. read). And the second will save the current contents of the Inventory::inventory ArrayList to a file (i.e. write). File format of both read and write is one line per piece of data, depending on what kind of resource the file is describing, various numbers of lines are required. Many types of FoodItems can be included in the same file. o Each resource will be in the following formats: O Fruit f item code item name Vegetable V item code item name Preserve P item code item name quantity of item quantity of item quantity of item item cost item cost item price item price name of the orchard farm supplier Please select one of the following: 1: Add Item to Inventory 2: Display Current Inventory 3: Buy Item(s) 4: Sell Item(s) 5: Search for Item 6: Save Inventory to File 7: Read Inventory from File 8: To Exit > item cost item price size of the jar Upon read, if you find a duplicate itemCode, you can abort reading in the file. Valid FoodItems before that one should remain in the inventory and an appropriate error message should be displayed. You don't know the name of the file so you cannot hard-code it in your program, you must prompt the user for the filename 4. Search: You will add the ability to view a FoodItem given the itemCode. 5. Menu Update: The new menu should look exactly like this: 6. When '5' is chosen by the user, the program will ask the user to enter the itemCode. See table for full details: When code doesn't exist When code is found, display details of the item associated to that code 7. When '6' is chosen by the user, the program will ask the user to enter the filename to save to. See table for full details: Enter the filename to save to: 8. When '7' is chosen by the user, the program will ask the user to enter the filename to read from. See table for full details: Enter the filename to read from: O 9. When '8' is chosen by the user, the message "Exiting..." is displayed and the program terminates. 10. You can add the following methods to your classes to accomplish the above. If you need any other methods, they must be private helper methods. o Inventory: Enter the code for the item: Code not found in inventory... Enter the code for the item: Item: 111 Granny Smith Apple 30 price: $0.25 cost: $0.10 orchard supplier: Apple Orchard FoodItem: Fruit: Updated: public boolean addItem (Scanner scanner, boolean fromFile) Added: public void searchForItem (Scanner scanner) Added: public void saveToFile (Scanner scanner) Added: public void readFromFile (Scanner scanner) Updated: public boolean addItem (Scanner scanner, boolean fromFile) Updated: public boolean inputCode (Scanner scanner, boolean fromFile) Added: public int getItemCode () Added: public void outputItem (Formatter writer) o Vegetable: Updated: public boolean addItem (Scanner scanner, boolean fromFile) Added: public void outputItem (Formatter writer) Updated: public boolean addItem (Scanner scanner, boolean fromFile) Added: public void outputItem (Formatter writer) 11. You must implement one of the comparison interfaces to compare FoodItems, either Comparator or Comparable. If you are implementing the Comparator interface, you will have a new class, if you are implementing Comparable, you will have a new method in one of your classes. 12. Remember, you must write EFFICIENT code. The changes above should allow you to improve the efficiency of some of the functionality from Assignment 1, that will be checked, ensure you take full advantage of the changes. Submission [Via Activities menu/Assignments option] Preserve: You must submit to the assignment link in Brightspace by the due date and time. Your submission should follow the Submission Checklist O Added: public void outputItem (Formatter writer) Updated: public boolean addItem (Scanner scanner, boolean fromFile) All source code i.e. .java files with headers NOTE: we will re-compile and run your program....so all code must be available to us and MUST NOT be in a package. Headers should contain name, student number, assignment number, date, purpose of class O O Javadoc: o A description of each data member and method should be described using Javadoc notation Generate the Javadoc for your solution and upload a zip of the generated folder with a member visibility of Private In Eclipse, go to Project->Generate Javadoc, select your project and "Create Javadoc for members with Visibility: Private" then click Finish. Test plan O o Can be in word or pdf format Should contain positive and negative testing (sometimes called happy path and unhappy path) o You should indicate which tests your program passes and which one fails Failure to provide any of the above will have an effect on your grade for this assignment. The assignment rubric will be published with the assignment submission link by the end of the week. Marking Scheme Item ArrayList: Marks 3 The Rules 1. You MUST use the default package in your assignment so that we can compile and run your program easily. 2. ALL data members MUST be declared as private (or protected in the Base class when necessary only). 3. Your program must be written using Object Oriented Principles (as outlined in the course notes and previous courses) and with efficiency in mind, you may lose marks for inefficient code. 4. Never leave compile warnings, address them without suppressing them! 5. A solution that does not compile will receive a grade of 0. Problem Description In this assignment, you will modify the solution to Assignment 1. You are to start with your solution to Assignment 1. You must also submit a test plan for the functionality created in this assignment. You must add to your test plan from assignment 1 to include testing the new functionality and addressing any feedback you have received. All requirements must still behave the same as described in assignment 1 unless overwritten by the requirements here. Requirements 1. Friendly Input: Ensure that your solution accepts spaces in any string input. Efficiency: You will update the inventory data structure in two ways: 2. o Change the inventory declaration in the Inventory class to be an object of ArrayList. Change the insert into the data structure so that the FoodItem objects are in numerical order from smallest to largest by itemCode in the most efficient way possible. Once the inventory structure is sorted, modify your other methods to also make them as efficient as possible. (Note - do NOT use Generic Collection methods yet - we will learn to do the coding ourselves first). 3. Saving data: You will add two menu selections to your assignment: O O Do NOT use the built-in binarysearch method - use your own custom-made binary search method. Hint: you can modify and reuse the binary search method you wrote in the earlier labs). You are allowed to use any built-in methods of the ArrayList collection. The first will read the contents of a file and add them to the Inventory::inventory ArrayList. (i.e. read). And the second will save the current contents of the Inventory::inventory ArrayList to a file (i.e. write). File format of both read and write is one line per piece of data, depending on what kind of resource the file is describing, various numbers of lines are required. Many types of FoodItems can be included in the same file. o Each resource will be in the following formats: O Fruit f item code item name Vegetable V item code item name Preserve P item code item name quantity of item quantity of item quantity of item item cost item cost item price item price name of the orchard farm supplier Please select one of the following: 1: Add Item to Inventory 2: Display Current Inventory 3: Buy Item(s) 4: Sell Item(s) 5: Search for Item 6: Save Inventory to File 7: Read Inventory from File 8: To Exit > item cost item price size of the jar Upon read, if you find a duplicate itemCode, you can abort reading in the file. Valid FoodItems before that one should remain in the inventory and an appropriate error message should be displayed. You don't know the name of the file so you cannot hard-code it in your program, you must prompt the user for the filename 4. Search: You will add the ability to view a FoodItem given the itemCode. 5. Menu Update: The new menu should look exactly like this: 6. When '5' is chosen by the user, the program will ask the user to enter the itemCode. See table for full details: When code doesn't exist When code is found, display details of the item associated to that code 7. When '6' is chosen by the user, the program will ask the user to enter the filename to save to. See table for full details: Enter the filename to save to: 8. When '7' is chosen by the user, the program will ask the user to enter the filename to read from. See table for full details: Enter the filename to read from: O 9. When '8' is chosen by the user, the message "Exiting..." is displayed and the program terminates. 10. You can add the following methods to your classes to accomplish the above. If you need any other methods, they must be private helper methods. o Inventory: Enter the code for the item: Code not found in inventory... Enter the code for the item: Item: 111 Granny Smith Apple 30 price: $0.25 cost: $0.10 orchard supplier: Apple Orchard FoodItem: Fruit: Updated: public boolean addItem (Scanner scanner, boolean fromFile) Added: public void searchForItem (Scanner scanner) Added: public void saveToFile (Scanner scanner) Added: public void readFromFile (Scanner scanner) Updated: public boolean addItem (Scanner scanner, boolean fromFile) Updated: public boolean inputCode (Scanner scanner, boolean fromFile) Added: public int getItemCode () Added: public void outputItem (Formatter writer) o Vegetable: Updated: public boolean addItem (Scanner scanner, boolean fromFile) Added: public void outputItem (Formatter writer) Updated: public boolean addItem (Scanner scanner, boolean fromFile) Added: public void outputItem (Formatter writer) 11. You must implement one of the comparison interfaces to compare FoodItems, either Comparator or Comparable. If you are implementing the Comparator interface, you will have a new class, if you are implementing Comparable, you will have a new method in one of your classes. 12. Remember, you must write EFFICIENT code. The changes above should allow you to improve the efficiency of some of the functionality from Assignment 1, that will be checked, ensure you take full advantage of the changes. Submission [Via Activities menu/Assignments option] Preserve: You must submit to the assignment link in Brightspace by the due date and time. Your submission should follow the Submission Checklist O Added: public void outputItem (Formatter writer) Updated: public boolean addItem (Scanner scanner, boolean fromFile) All source code i.e. .java files with headers NOTE: we will re-compile and run your program....so all code must be available to us and MUST NOT be in a package. Headers should contain name, student number, assignment number, date, purpose of class O O Javadoc: o A description of each data member and method should be described using Javadoc notation Generate the Javadoc for your solution and upload a zip of the generated folder with a member visibility of Private In Eclipse, go to Project->Generate Javadoc, select your project and "Create Javadoc for members with Visibility: Private" then click Finish. Test plan O o Can be in word or pdf format Should contain positive and negative testing (sometimes called happy path and unhappy path) o You should indicate which tests your program passes and which one fails Failure to provide any of the above will have an effect on your grade for this assignment. The assignment rubric will be published with the assignment submission link by the end of the week. Marking Scheme Item ArrayList: Marks 3
Expert Answer:
Related Book For
Database Systems Design Implementation and Management
ISBN: 978-1337627900
13th edition
Authors: Carlos Coronel, Steven Morris
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
In the Walton Bookstore example with a discrete demand distribution, explain why an order quantity other than one of the possible demands cannot maximize the expected profit.
-
What are the three categories into which NFPs must classify their net assets? Describe which net assets are included in each category. Would board-designated net assets be reported as temporarily...
-
ht Data for Hermann Corporation are shown below: Selling price Variable expenses Contribution margin Per Unit Percent of Sales $ 60 39 100% 65 $ 21 35% Fixed expenses are $72,000 per month and the...
-
What does the phrase theory of the case mean? Why is it important to develop a theory of the case in advance of trial?
-
Listed are the equity sections of balance sheets for years 2011 and 2012 as reported by Mountain Air Ski Resorts, Inc. The overall value of stockholders equity has risen from $2,000,000 to...
-
Idk Problem 3: A wind turbine is shown below. We are interested in the position of the blade tip B. In the x,y coordinate system, the tip of the blade is given by the coordinates (x,y) = (50, 300)...
-
The financial statements of Aritzia Inc. are presented in Appendix A at the end of this textbook. Instructions a. What title does Aritzia use for its income statement? What title does Aritzia use for...
-
You work for a waste management company, and your job is to sort out the recycled material from the customers whose recycling your company picked up. Today, you are going through the recycled...
-
Solve: 4 = log(625) b =
-
Amato is preparing a resume to apply for a higher-level management position with Amato's current company. The position Amato is applying for is in a different location from Amato's current job. What...
-
b. 1. Evaluate each of the following. (2 marks - 0.5 marks each) 5 a. 2 2 35 52 d. -3 3
-
Barney Grant, the President of Parts Plus Corporation, a Michigan Corporation, has come to your office for legal advice. In your interview with Mr. Grant, he reveals the following information about...
-
On August 30, JumpStart paid the following expenses: August rent, $2,300 August's utility bill, $525 Employee wages, $1,750 Parking lot cleaning fee, $27 Journalize these payments as one journal...
-
Question 22 (1 point) A disadvantage of the fixed-period inventory system is that additional inventory records are required. it involves higher ordering costs than the fixed quantity inventory...
-
Three forces with magnitudes of 70pounds, 40 pounds, and 60 pounds act on an object at angles of 30, 45, and 135, respectively, with the positive x-axis. Find the direction and magnitude of the...
-
Is data visualization only useful when used with Big Data? Explain and Expand.
-
Identify and explain some of the critical success factors in the development and implementation of a good data administration strategy.
-
How would you define object orientation? What are some of its benefits? How are OO programming languages related to object orientation?
-
Find the z-scores that bound the middle 70% of the area under the standard normal curve.
-
Find the z-scores that bound the middle 80% of the area under the standard normal curve.
-
Find the z-scores that bound the middle 98% of the area under the standard normal curve.
Study smarter with the SolutionInn App