Advertisement
ConnorSiebens

InventoryItem

Jan 7th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Random;
  3. public class InventoryItem {
  4.     /**
  5.      * @ConnorSiebens
  6.      * Create a class to keep track of inventory items. Call it InventoryItem
  7.      * Create instance variables for part number, quantity, description and cost.
  8.      * Create static variables for total inventory and total value ($)
  9.      * Create the constructors, accessors and mutators needed to keep track of the inventory.
  10.      * Also create a toString method to print the information about each piece.
  11.      * Create a program to create inventory items and add/subtract from their quantities.
  12.      */
  13.     public int pnum,quant;
  14.     public static int cost[];
  15.     public static Random rand = new Random();
  16.     public static String desc[];
  17.     public static String user;
  18.     public static boolean cont=true;
  19.     public static int tinv=0,tval=0;
  20.     public static  Scanner keyboard = new Scanner(System.in);  
  21.     public static void main(String[] args) {
  22.         while(cont){
  23.             System.out.println("Would you like to (add), (remove), or (lookup) an item? Or enter none of them to exit.");
  24.             user = keyboard.nextLine();
  25.             if(user.equals("add")){
  26.                 System.out.println("Enter a description for the part.");
  27.                 desc[tinv]=desc();
  28.                 System.out.println("Enter a cost for the item.");
  29.                 cost();
  30.                 tinv+=1;
  31.             }else if(user=="remove"){
  32.                
  33.             }else if(user=="lookup"){
  34.                
  35.             }else{
  36.                 cont=false;
  37.             }
  38.         }
  39.     }
  40.     public static int rand(){
  41.         return(rand.nextInt(10000) + 1);
  42.     }
  43.     public static String desc(){
  44.         return keyboard.nextLine();
  45.     }
  46.     public static int cost(){
  47.         return keyboard.nextInt();
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement