Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- public class InventoryItem {
- /**
- * @ConnorSiebens
- * Create a class to keep track of inventory items. Call it InventoryItem
- * Create instance variables for part number, quantity, description and cost.
- * Create static variables for total inventory and total value ($)
- * Create the constructors, accessors and mutators needed to keep track of the inventory.
- * Also create a toString method to print the information about each piece.
- * Create a program to create inventory items and add/subtract from their quantities.
- */
- public int pnum,quant;
- public static int cost[];
- public static Random rand = new Random();
- public static String desc[];
- public static String user;
- public static boolean cont=true;
- public static int tinv=0,tval=0;
- public static Scanner keyboard = new Scanner(System.in);
- public static void main(String[] args) {
- while(cont){
- System.out.println("Would you like to (add), (remove), or (lookup) an item? Or enter none of them to exit.");
- user = keyboard.nextLine();
- if(user.equals("add")){
- System.out.println("Enter a description for the part.");
- desc[tinv]=desc();
- System.out.println("Enter a cost for the item.");
- cost();
- tinv+=1;
- }else if(user=="remove"){
- }else if(user=="lookup"){
- }else{
- cont=false;
- }
- }
- }
- public static int rand(){
- return(rand.nextInt(10000) + 1);
- }
- public static String desc(){
- return keyboard.nextLine();
- }
- public static int cost(){
- return keyboard.nextInt();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement