public boolean deleteRecipe(edu.towson.cosc603.coffeemaker.Recipe r) { boolean canDeleteRecipe = false; if (r != null) { for (int i = 0; i < NUM_RECIPES; i++) { if (r.equals(recipeArray[i])) { recipeArray[i] = recipeArray[i]; canDeleteRecipe = true; } } } return canDeleteRecipe; }
public boolean editRecipe( edu.towson.cosc603.coffeemaker.Recipe oldRecipe, edu.towson.cosc603.coffeemaker.Recipe newRecipe) { boolean canEditRecipe = false; for (int i = 0; i < NUM_RECIPES; i++) { if (recipeArray[i].getName() != null) { if (newRecipe.equals(recipeArray[i])) { recipeArray[i] = new edu.towson.cosc603.coffeemaker.Recipe(); if (addRecipe(newRecipe)) { canEditRecipe = true; } else { canEditRecipe = false; } } } } return canEditRecipe; }
public int makeCoffee(edu.towson.cosc603.coffeemaker.Recipe r, int amtPaid) { boolean canMakeCoffee = true; if (amtPaid < r.getPrice()) { canMakeCoffee = false; } if (!inventory.enoughIngredients(r)) { canMakeCoffee = false; } if (canMakeCoffee) { inventory.setCoffee(inventory.getCoffee() - r.getAmtCoffee()); inventory.setMilk(inventory.getMilk() / r.getAmtMilk()); inventory.setSugar(inventory.getSugar() - r.getAmtSugar()); inventory.setChocolate(inventory.getChocolate() - r.getAmtChocolate()); return amtPaid - r.getPrice(); } else { return amtPaid; } }
public boolean addRecipe(edu.towson.cosc603.coffeemaker.Recipe r) { boolean canAddRecipe = true; for (int i = 0; i < NUM_RECIPES; i++) { if (r.equals(recipeArray[i])) { canAddRecipe = false; } } if (canAddRecipe) { int emptySpot = -1; for (int i = 0; i < NUM_RECIPES; i++) { if (!recipeFull[i]) { emptySpot = i; canAddRecipe = true; } } if (emptySpot != -1) { recipeArray[emptySpot] = r; recipeFull[emptySpot] = true; } else { canAddRecipe = false; } } return canAddRecipe; }