1, makeCoffee, Main, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Main.java, 217, 244 3 /** * Make coffee user interface the processes input. */ 28 public static void makeCoffee() { Recipe [] recipes = coffeeMaker.getRecipes(); for(int i = 0; i < recipes.length; i++) { if (recipes[i] != null) { System.out.println((i+1) + ". " + recipes[i].getName()); } } int recipeToPurchase = recipeListSelection("Please select the number of the recipe to purchase."); String amountPaid = inputOutput("Please enter the amount you wish to pay"); int amtPaid = 0; try { amtPaid = Integer.parseInt(amountPaid); } catch (NumberFormatException e) { System.out.println("Please enter a positive integer"); mainMenu(); } int change = coffeeMaker.makeCoffee(recipeToPurchase, amtPaid); if (change == amtPaid) { System.out.println("Insufficient funds to purchase."); } else { System.out.println("Thank you for purchasing " + coffeeMaker.getRecipes()[recipeToPurchase].getName()); } System.out.println("Your change is: " + change + "\n"); mainMenu(); ### 2, deleteRecipe, Main, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Main.java, 103, 123 3 /** * Delete recipe user interface that processes input. */ 21 public static void deleteRecipe() { Recipe [] recipes = coffeeMaker.getRecipes(); for(int i = 0; i < recipes.length; i++) { if (recipes[i] != null) { System.out.println((i+1) + ". " + recipes[i].getName()); } } int recipeToDelete = recipeListSelection("Please select the number of the recipe to delete."); if(recipeToDelete < 0) { mainMenu(); } String recipeDeleted = coffeeMaker.deleteRecipe(recipeToDelete); if (recipeDeleted != null) { System.out.println(recipeDeleted + " successfully deleted.\n"); } else { System.out.println("Selected recipe doesn't exist and could not be deleted.\n"); } mainMenu(); ### 3, mainMenu, Main, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Main.java, 23, 50 4 /** * Prints the main menu and handles user input for * main menu commands. */ 28 public static void mainMenu() { System.out.println("1. Add a recipe"); System.out.println("2. Delete a recipe"); System.out.println("3. Edit a recipe"); System.out.println("4. Add inventory"); System.out.println("5. Check inventory"); System.out.println("6. Make coffee"); System.out.println("0. Exit\n"); //Get user input try { int userInput = Integer.parseInt(inputOutput("Please press the number that corresponds to what you would like the coffee maker to do.")); if (userInput >= 0 && userInput <=6) { if (userInput == 1) addRecipe(); if (userInput == 2) deleteRecipe(); if (userInput == 3) editRecipe(); if (userInput == 4) addInventory(); if (userInput == 5) checkInventory(); if (userInput == 6) makeCoffee(); if (userInput == 0) System.exit(0); } else { System.out.println("Please enter a number from 0 - 6"); mainMenu(); } } catch (NumberFormatException e) { System.out.println("Please enter a number from 0 - 6"); mainMenu(); ### 4, inputOutput, Main, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Main.java, 253, 264 6 /** * Passes a prompt to the user and returns the user specified * string. * @param message * @return String */ 12 private static String inputOutput(String message) { System.out.println(message); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String returnString = ""; try { returnString = br.readLine(); } catch (IOException e){ System.out.println("Error reading in value"); mainMenu(); } return returnString; ### 5, addInventory, Main, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Main.java, 183, 202 3 /** * Add inventory user interface that processes input. */ 20 public static void addInventory() { //Read in amt coffee String coffeeString = inputOutput("\nPlease enter the units of coffee to add: "); //Read in amt milk String milkString = inputOutput("\nPlease enter the units of milk to add: "); //Read in amt sugar String sugarString = inputOutput("\nPlease enter the units of sugar to add: "); //Read in amt chocolate String chocolateString = inputOutput("\nPlease enter the units of chocolate to add: "); try { coffeeMaker.addInventory(coffeeString, milkString, sugarString, chocolateString); System.out.println("Inventory successfully added"); } catch (InventoryException e) { System.out.println("Inventory was not added"); } finally { mainMenu(); ### 6, editRecipe, Main, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Main.java, 129, 176 3 /** * Edit recipe user interface the processes user input. */ 48 public static void editRecipe() { Recipe [] recipes = coffeeMaker.getRecipes(); for(int i = 0; i < recipes.length; i++) { if (recipes[i] != null) { System.out.println((i+1) + ". " + recipes[i].getName()); } } int recipeToEdit = recipeListSelection("Please select the number of the recipe to edit."); if(recipeToEdit < 0) { mainMenu(); } //Read in recipe price String priceString = inputOutput("\nPlease enter the recipe price: $"); //Read in amt coffee String coffeeString = inputOutput("\nPlease enter the units of coffee in the recipe: "); //Read in amt milk String milkString = inputOutput("\nPlease enter the units of milk in the recipe: "); //Read in amt sugar String sugarString = inputOutput("\nPlease enter the units of sugar in the recipe: "); //Read in amt chocolate String chocolateString = inputOutput("\nPlease enter the units of chocolate in the recipe: "); Recipe newRecipe = new Recipe(); try { newRecipe.setPrice(priceString); newRecipe.setAmtCoffee(coffeeString); newRecipe.setAmtMilk(milkString); newRecipe.setAmtSugar(sugarString); newRecipe.setAmtChocolate(chocolateString); String recipeEdited = coffeeMaker.editRecipe(recipeToEdit, newRecipe); if (recipeEdited != null) { System.out.println(recipeEdited + " successfully edited.\n"); } else { System.out.println(recipeEdited + "could not be edited.\n"); } } catch (RecipeException e) { System.out.println(e.getMessage()); } finally { mainMenu(); ### 7, recipeListSelection, Main, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Main.java, 273, 287 6 /** * Passes a prompt to the user that deals with the recipe list * and returns the user selected number. * @param message * @return int */ 15 private static int recipeListSelection(String message) { String userSelection = inputOutput(message); int recipe = 0; try { recipe = Integer.parseInt(userSelection) - 1; if (recipe >= 0 && recipe <=2) { //do nothing here. } else { recipe = -1; } } catch (NumberFormatException e) { System.out.println("Please select a number from 1-3."); recipe = -1; } return recipe; ### 8, addRecipe, Main, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Main.java, 57, 96 3 /** * The add recipe user interface that process user input. */ 40 public static void addRecipe() { //Read in recipe name String name = inputOutput("\nPlease enter the recipe name: "); //Read in recipe price String priceString = inputOutput("\nPlease enter the recipe price: $"); //Read in amt coffee String coffeeString = inputOutput("\nPlease enter the units of coffee in the recipe: "); //Read in amt milk String milkString = inputOutput("\nPlease enter the units of milk in the recipe: "); //Read in amt sugar String sugarString = inputOutput("\nPlease enter the units of sugar in the recipe: "); //Read in amt chocolate String chocolateString = inputOutput("\nPlease enter the units of chocolate in the recipe: "); Recipe r = new Recipe(); try { r.setName(name); r.setPrice(priceString); r.setAmtCoffee(coffeeString); r.setAmtMilk(milkString); r.setAmtSugar(sugarString); r.setAmtChocolate(chocolateString); boolean recipeAdded = coffeeMaker.addRecipe(r); if(recipeAdded) { System.out.println(name + " successfully added.\n"); } else { System.out.println(name + " could not be added.\n"); } } catch (RecipeException e) { System.out.println(e.getMessage()); } finally { mainMenu(); ### 9, checkInventory, Main, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Main.java, 209, 211 3 /** * Check inventory user interface that processes input. */ 3 public static void checkInventory() { System.out.println(coffeeMaker.checkInventory()); mainMenu(); ### 10, getRecipes, RecipeBook, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/RecipeBook.java, 22, 23 5 /** * Returns the recipe array. * @param r * @return Recipe[] */ 2 public synchronized Recipe[] getRecipes() { return recipeArray; ### 11, deleteRecipe, RecipeBook, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/RecipeBook.java, 57, 63 6 /** * Returns the name of the recipe deleted at the position specified * and null if the recipe does not exist. * @param recipeToDelete * @return String */ 7 public synchronized String deleteRecipe(int recipeToDelete) { if (recipeArray[recipeToDelete] != null) { String recipeName = recipeArray[recipeToDelete].getName(); recipeArray[recipeToDelete] = null; return recipeName; } else { return null; ### 12, RecipeBook, RecipeBook, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/RecipeBook.java, 13, 14 3 /** * Default constructor for a RecipeBook. */ 2 public RecipeBook() { recipeArray = new Recipe[NUM_RECIPES]; ### 13, makeCoffee, CoffeeMaker, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/CoffeeMaker.java, 86, 101 7 /** * Returns the change of a user's beverage purchase, or * the user's money if the beverage cannot be made * @param r * @param amtPaid * @return int */ 16 public synchronized int makeCoffee(int recipeToPurchase, int amtPaid) { int change = 0; if (getRecipes()[recipeToPurchase] == null) { change = amtPaid; } else if (getRecipes()[recipeToPurchase].getPrice() <= amtPaid) { if (inventory.useIngredients(getRecipes()[recipeToPurchase])) { change = amtPaid - getRecipes()[recipeToPurchase].getPrice(); } else { change = amtPaid; } } else { change = amtPaid; } return change; ### 14, addInventory, CoffeeMaker, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/CoffeeMaker.java, 64, 68 8 /** * Returns true if inventory was successfully added * @param amtCoffee * @param amtMilk * @param amtSugar * @param amtChocolate * @return boolean */ 5 public synchronized void addInventory(String amtCoffee, String amtMilk, String amtSugar, String amtChocolate) throws InventoryException { inventory.addCoffee(amtCoffee); inventory.addMilk(amtMilk); inventory.addSugar(amtSugar); inventory.addChocolate(amtChocolate); ### 15, checkInventory, CoffeeMaker, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/CoffeeMaker.java, 75, 76 4 /** * Returns the inventory of the coffee maker * @return Inventory */ 2 public synchronized String checkInventory() { return inventory.toString(); ### 16, deleteRecipe, CoffeeMaker, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/CoffeeMaker.java, 41, 42 7 /** * Returns the name of the successfully deleted recipe * or null if the recipe cannot be deleted. * * @param recipeToDelete * @return String */ 2 public String deleteRecipe(int recipeToDelete) { return recipeBook.deleteRecipe(recipeToDelete); ### 17, editRecipe, CoffeeMaker, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/CoffeeMaker.java, 52, 53 7 /** * Returns the name of the successfully edited recipe * or null if the recipe cannot be edited. * @param recipeToEdit * @param r * @return String */ 2 public String editRecipe(int recipeToEdit, Recipe r) { return recipeBook.editRecipe(recipeToEdit, r); ### 18, CoffeeMaker, CoffeeMaker, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/CoffeeMaker.java, 18, 20 4 /** * Constructor for the coffee maker * */ 3 public CoffeeMaker() { recipeBook = new RecipeBook(); inventory = new Inventory(); ### 19, addRecipe, CoffeeMaker, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/CoffeeMaker.java, 30, 31 7 /** * Returns true if the recipe is added to the * list of recipes in the CoffeeMaker and false * otherwise. * @param r * @return boolean */ 2 public boolean addRecipe(Recipe r) { return recipeBook.addRecipe(r); ### 20, setAmtChocolate, Recipe, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Recipe.java, 37, 47 3 /** * @param amtChocolate The amtChocolate to set. */ 11 public void setAmtChocolate(String chocolate) throws RecipeException { int amtChocolate = 0; try { amtChocolate = Integer.parseInt(chocolate); } catch (NumberFormatException e) { throw new RecipeException("Units of chocolate must be a positive integer"); } if (amtChocolate >= 0) { this.amtChocolate = amtChocolate; } else { throw new RecipeException("Units of chocolate must be a positive integer"); ### 21, getPrice, Recipe, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Recipe.java, 133, 134 3 /** * @return Returns the price. */ 2 public int getPrice() { return price; ### 22, setPrice, Recipe, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Recipe.java, 139, 149 3 /** * @param price The price to set. */ 11 public void setPrice(String price) throws RecipeException{ int amtPrice = 0; try { amtPrice = Integer.parseInt(price); } catch (NumberFormatException e) { throw new RecipeException("Price must be a positive integer"); } if (amtPrice >= 0) { this.price = amtPrice; } else { throw new RecipeException("Price must be a positive integer"); ### 23, getAmtCoffee, Recipe, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Recipe.java, 53, 54 3 /** * @return Returns the amtCoffee. */ 2 public int getAmtCoffee() { return amtCoffee; ### 24, setAmtMilk, Recipe, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Recipe.java, 81, 91 3 /** * @param amtMilk The amtMilk to set. */ 11 public void setAmtMilk(String milk) throws RecipeException{ int amtMilk = 0; try { amtMilk = Integer.parseInt(milk); } catch (NumberFormatException e) { throw new RecipeException("Units of milk must be a positive integer"); } if (amtMilk >= 0) { this.amtMilk = amtMilk; } else { throw new RecipeException("Units of milk must be a positive integer"); ### 25, getAmtMilk, Recipe, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Recipe.java, 75, 76 3 /** * @return Returns the amtMilk. */ 2 public int getAmtMilk() { return amtMilk; ### 26, setAmtCoffee, Recipe, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Recipe.java, 59, 69 3 /** * @param amtCoffee The amtCoffee to set. */ 11 public void setAmtCoffee(String coffee) throws RecipeException { int amtCoffee = 0; try { amtCoffee = Integer.parseInt(coffee); } catch (NumberFormatException e) { throw new RecipeException("Units of coffee must be a positive integer"); } if (amtCoffee >= 0) { this.amtCoffee = amtCoffee; } else { throw new RecipeException("Units of coffee must be a positive integer"); ### 27, getAmtSugar, Recipe, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Recipe.java, 97, 98 3 /** * @return Returns the amtSugar. */ 2 public int getAmtSugar() { return amtSugar; ### 28, getName, Recipe, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Recipe.java, 119, 120 3 /** * @return Returns the name. */ 2 public String getName() { return name; ### 29, getAmtChocolate, Recipe, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Recipe.java, 31, 32 3 /** * @return Returns the amtChocolate. */ 2 public int getAmtChocolate() { return amtChocolate; ### 30, setName, Recipe, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Recipe.java, 125, 127 3 /** * @param name The name to set. */ 3 public void setName(String name) { if(name != null) { this.name = name; ### 31, Recipe, Recipe, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Recipe.java, 19, 25 3 /** * Creates a default recipe for the coffee maker. */ 7 public Recipe() { this.name = ""; this.price = 0; this.amtCoffee = 0; this.amtMilk = 0; this.amtSugar = 0; this.amtChocolate = 0; ### 32, setAmtSugar, Recipe, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Recipe.java, 103, 113 3 /** * @param amtSugar The amtSugar to set. */ 11 public void setAmtSugar(String sugar) throws RecipeException { int amtSugar = 0; try { amtSugar = Integer.parseInt(sugar); } catch (NumberFormatException e) { throw new RecipeException("Units of sugar must be a positive integer"); } if (amtSugar >= 0) { this.amtSugar = amtSugar; } else { throw new RecipeException("Units of sugar must be a positive integer"); ### 33, setMilk, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 123, 125 5 /** * Sets the number of milk units in the inventory * to the specified amount. * @param milk */ 3 public synchronized void setMilk(int milk) { if(milk >= 0) { Inventory.milk = milk; ### 34, getChocolate, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 33, 34 5 /** * Returns the current number of chocolate units in * the inventory. * @return int */ 2 public int getChocolate() { return chocolate; ### 35, addSugar, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 175, 185 6 /** * Add the number of sugar units in the inventory * to the current amount of sugar units. * @param sugar * @throws InventoryException */ 11 public synchronized void addSugar(String sugar) throws InventoryException { int amtSugar = 0; try { amtSugar = Integer.parseInt(sugar); } catch (NumberFormatException e) { throw new InventoryException("Units of sugar must be a positive integer"); } if (amtSugar >= 0) { Inventory.sugar += amtSugar; } else { throw new InventoryException("Units of sugar must be a positive integer"); ### 36, setSugar, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 163, 165 5 /** * Sets the number of sugar units in the inventory * to the specified amount. * @param sugar */ 3 public synchronized void setSugar(int sugar) { if(sugar >= 0) { Inventory.sugar = sugar; ### 37, getSugar, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 154, 155 5 /** * Returns the current number of sugar units in * the inventory. * @return int */ 2 public int getSugar() { return sugar; ### 38, useIngredients, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 218, 226 6 /** * Removes the ingredients used to make the specified * recipe. Assumes that the user has checked that there * are enough ingredients to make * @param r */ 9 public synchronized boolean useIngredients(Recipe r) { if (enoughIngredients(r)) { Inventory.coffee -= r.getAmtCoffee(); Inventory.milk -= r.getAmtMilk(); Inventory.sugar -= r.getAmtSugar(); Inventory.chocolate -= r.getAmtChocolate(); return true; } else { return false; ### 39, setCoffee, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 83, 85 5 /** * Sets the number of coffee units in the inventory * to the specified amount. * @param coffee */ 3 public synchronized void setCoffee(int coffee) { if(coffee >= 0) { Inventory.coffee = coffee; ### 40, addChocolate, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 55, 65 6 /** * Add the number of chocolate units in the inventory * to the current amount of chocolate units. * @param chocolate * @throws InventoryException */ 11 public synchronized void addChocolate(String chocolate) throws InventoryException { int amtChocolate = 0; try { amtChocolate = Integer.parseInt(chocolate); } catch (NumberFormatException e) { throw new InventoryException("Units of chocolate must be a positive integer"); } if (amtChocolate >= 0) { Inventory.chocolate += amtChocolate; } else { throw new InventoryException("Units of chocolate must be a positive integer"); ### 41, setChocolate, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 42, 44 5 /** * Sets the number of chocolate units in the inventory * to the specified amount. * @param chocolate */ 3 public synchronized void setChocolate(int chocolate) { if(chocolate >= 0) { Inventory.chocolate = chocolate; ### 42, getCoffee, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 74, 75 5 /** * Returns the current number of coffee units in * the inventory. * @return int */ 2 public int getCoffee() { return coffee; ### 43, getMilk, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 114, 115 5 /** * Returns the current number of milk units in * the inventory. * @return int */ 2 public int getMilk() { return milk; ### 44, enoughIngredients, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 195, 209 6 /** * Returns true if there are enough ingredients to make * the beverage. * @param r * @return boolean */ 15 protected synchronized boolean enoughIngredients(Recipe r) { boolean isEnough = true; if(Inventory.coffee < r.getAmtCoffee()) { isEnough = false; } if(Inventory.milk < r.getAmtMilk()) { isEnough = false; } if(Inventory.sugar < r.getAmtSugar()) { isEnough = false; } if(Inventory.chocolate < r.getAmtChocolate()) { isEnough = false; } return isEnough; ### 45, addMilk, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 135, 145 6 /** * Add the number of milk units in the inventory * to the current amount of milk units. * @param milk * @throws InventoryException */ 11 public synchronized void addMilk(String milk) throws InventoryException { int amtMilk = 0; try { amtMilk = Integer.parseInt(milk); } catch (NumberFormatException e) { throw new InventoryException("Units of milk must be a positive integer"); } if (amtMilk >= 0) { Inventory.milk += amtMilk; } else { throw new InventoryException("Units of milk must be a positive integer"); ### 46, Inventory, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 21, 25 4 /** * Creates a coffee maker inventory object and * fills each item in the inventory with 15 units. */ 5 public Inventory() { setCoffee(15); setMilk(15); setSugar(15); setChocolate(15); ### 47, addCoffee, Inventory, CoffeeMaker10 CoffeeMaker_Web/src/edu/ncsu/csc326/coffeemaker/Inventory.java, 95, 105 6 /** * Add the number of coffee units in the inventory * to the current amount of coffee units. * @param coffee * @throws InventoryException */ 11 public synchronized void addCoffee(String coffee) throws InventoryException { int amtCoffee = 0; try { amtCoffee = Integer.parseInt(coffee); } catch (NumberFormatException e) { throw new InventoryException("Units of coffee must be a positive integer"); } if (amtCoffee >= 0) { Inventory.coffee += amtCoffee; } else { throw new InventoryException("Units of coffee must be a positive integer"); ###