Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java - Inventory

dud3adm
dud3adm 


For this homework you will re-factor the Inventory management program from HW 7. This assignment will give you practice with object arrays and methods. 1. (Total 11 points) Design a Java class called Item (Item.java). a. (3 points) There should be 3 data fields with private visibility: name, quantity, pricePerUnit. b. (8 points) Include all the getter/setter methods, and constructor(s). 2. (Total 34 points) Write another java class file called InventoryManager.java. In the main method of this class code the following a. (18 points) Read Inventory: i. (6 points) Use File class and Scanner class to read the items and related information from the file provided with this assignment. ii. (6 points) For every item in this file create a new object of the Item class with appropriate values. iii. (6 points) Let all the objects be a part of an array. There are 10 items in the file. b. Display to the user the possible operations on the inventory and prompt her/him to choose one. The details of the possible operations are: c. (5 points) Print inventory (p): Write a method printInventory to which pass the array of objects as an input parameter. The method prints the inventory in the following format: Item Name, Quantity, Price Per Piece d. (6 points) Check for low inventory (c): Write a method called checkLowInventory to which pass the array of objects as an input parameter. This method checks for items that have fewer quantity than 5, and prints them in the same format as in option (p). If there is no such item then print an appropriate message. e. (5 points) Total inventory value (v): Write a method called totalInventoryValue to which pass the array of objects as an input parameter. This method computes the total value of the current inventory using the quantity and price per piece information, and prints that total value. f. Exit (e): Exists the program. Using netbeans: For this homework assignment (no13 you will need to extend an old assignment (no7) I'm going to attach java file for the homework 7 and its pdf file (old stuff) The new assignment's pdf file+ txt file that teacher included Attachments Tags Clarifications

Answers

Java - Inventory - Solution

dickersonka
dickersonka 



Attached is the solution to the Java - Inventory assignment including source and comments Attachments
Inventory.zip (1 K) Download
Preview
scissors 398 4 eraser 199 2 paper-weight 50 3

Preview
//determine choice if(choice.equals("p")){ printInventory(items); }else if(choice.equals("c")){ checkLowInventory(items); }else if(choice.equals("v")){ totalInventoryValue(items); }else if(choice.equals("e")){ System.out.println("Goodbye"); } } } private static Item[] readFile(String fileName) throws FileNotFoundException{ //open file for reading Scanner reader = new Scanner(new File(fileName));

Preview
this.pricePerUnit = pricePerUnit; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getQuantity() {

Inventory_Screenshot.png (28 K) Download Preview

Screenshots
Screenshot
Purchase Answer

Assignment 13 - Solution

mariobeka
mariobeka 



Below you will find the netbeans java projects containing the two java files
Item.java and InventoryManager.java. Comments included.
Attachments
Screen Shot 2014-05-09 at 4.57.12 AM.png (48 K) Download Preview

Assignment13.zip (15 K) Download



Preview
2 notepad 1050 5 paint-brush 500 3 scissors

Preview
building -post-jar: called after JAR building -post-clean: called after cleaning build products (Targets beginning with '-' are not intended to be called on their own.) Example of inserting an obfuscator after compilation could look like this: <target name="-post-compile"> <obfuscate> <fileset dir="${build.classes.dir}"/> </obfuscate> </target> For list of available properties check the

Preview
</target> <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps"> <mkdir dir="${build.dir}"/> <touch file="${built-clean.properties}" verbose="false"/> <property file="${built-clean.properties}" prefix="already.built.clean."/> <antcall target="-warn-already-built-clean"/> <propertyfile file="${built-clean.properties}"> <entry key="${basedir}" value=""/> </propertyfile> </target> <target depends="init" name="-do-clean"> <delete dir="${build.dir}"/> <delete dir="${d

Preview
<configuration> <data xmlns="http://www.netbeans.org/ns/j2se-project/3"> <name>Assignment13</name> <source-roots>

Preview
list = new Item[9]; // Creating the objects while (reader.hasNext()) { s = reader.nextLine(); st = new StringTokenizer(s); list[x++] = new Item(st.nextToken(), Double.parseDouble(st .nextToken()), Integer.parseInt(st.nextToken())); } // Point c System.out.println("Please choose one of the following options:"); System.out.println("\tPrint Inventory (p)"); System.out.println("\tCheck for low inventory (c)"); System.out.println("\tTotal inventory value (v)"); System.out.println("\tE

Preview
/** * @param name the name to set */ public void setName(String name) { this.name = name; } /** * @return the quantity */ public int getQuantity() { return quantity; } /** * @param quantity the quantity to set */

Screenshots
Screenshot
Purchase Answer