Okay after much thought and deliberation over this thing here's what I have accomplished:
import java.util.*;
public class Driver {
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
ArrayList <Inventory>ingredients = new ArrayList<Inventory>();
String name;
String measurement;
int units;
int menuChoice=menu();
int i;
int addOn;
while(menuChoice!=5)
{
if(menuChoice==1)
{
System.out.println("What type of ingredient would you like to add?");
name=keyboard.nextLine();
System.out.println("What is "+name+" measured in?");
measurement=keyboard.nextLine();
System.out.println("");
System.out.println("How many "+measurement+" of "+name+" do you have?");
units=keyboard.nextInt();
keyboard.nextLine();
System.out.println("");
Inventory foodItem = new Inventory(name, measurement, units);
ingredients.add(foodItem);
}
else if(menuChoice==2)
{
for(i=0; i<ingredients.size(); i++)
{
System.out.println(i +") "+ingredients.get(i).toString());
}
System.out.println("What would you like to add to?");
int x = keyboard.nextInt();
addOn=ingredients.get(x).getUnits();
System.out.println("How many "+ingredients.get(x).getMeasurment()+" would you like to stock?");
addOn+=keyboard.nextInt();
ingredients.get(x).setUnits(addOn);
}
else if (menuChoice==3)
{
for(i=0; i<ingredients.size(); i++)
{
System.out.println(i +") "+ingredients.get(i).toString());
}
System.out.println("Which item would you like to use?");
int x = keyboard.nextInt();
addOn=ingredients.get(x).getUnits();
System.out.println("How many "+ingredients.get(x).getMeasurment()+" would you like to use?");
addOn-=keyboard.nextInt();
ingredients.get(x).setUnits(addOn);
}
else if (menuChoice==4)
{
for(i=0; i<ingredients.size(); i++)
System.out.println(ingredients.get(i).toString());
}
menuChoice=menu();
}
}
public static int menu()
{
Scanner keyboard = new Scanner(System.in);
int menuChoice;
System.out.println("Please select an option");
System.out.println("1)Add inventory");
System.out.println("2)Stock inventory");
System.out.println("3)Use ingredients");
System.out.println("4)Display ingredients");
System.out.println("5)Exit program");
menuChoice = keyboard.nextInt();
while(menuChoice < 1 || menuChoice > 5)
{
System.out.println("Invalid please try again");
menuChoice = keyboard.nextInt();
}
return menuChoice;
}
}
And for my inventory class:
public class Inventory
{
int units;
String name;
String measurment;
public Inventory(String nameIn,String measurmentIn, int unitsIn)
{
name=nameIn;
measurment=measurmentIn;
units=unitsIn;
}
public int getUnits() {
return units;
}
public void setUnits(int units) {
this.units = units;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMeasurment() {
return measurment;
}
public void setMeasurment(String measurment) {
this.measurment = measurment;
}
public String toString()
{
String foodInfo="you have "+units+" "+measurment+" of "+name;
return foodInfo;
}
}
Now I have a couple more questions, I need to set parameter limits on using inventory. As in, if you use more than whats in stock print out an error message to the user. And for the other question, How would I make it to when an item gets to 0 It will delete it's self from the ArraylList?
Also once again, any comments, suggestions to improve, and any catch in an error would be very much appreciated <3. Thanks again