@Test
  public void shouldNotUpdatePairingIfOneExists() {
    FlavorPair flavorPair = new FlavorPair();
    flavorPair.setIngredient1("Chicken");
    flavorPair.setIngredient2("Carrot");
    flavorPair.setCategory1("Meat");
    flavorPair.setCategory2("Vegetable");
    flavorPair.setAffinity(Affinity.EXCELLENT.name());
    flavorController.addPair(flavorPair);

    FlavorPair flavorPair2 = new FlavorPair();
    flavorPair2.setIngredient1("Chicken");
    flavorPair2.setIngredient2("Carrot");
    flavorPair2.setCategory1("Meat");
    flavorPair2.setCategory2("Vegetable");
    flavorPair2.setAffinity(Affinity.GOOD.name());
    flavorController.addPair(flavorPair2);

    Ingredient chicken = ingredientRepository.findByName("Chicken").iterator().next();
    assertEquals(1, chicken.getPairings().size());
    Pairing pairing = chicken.getPairings().iterator().next();
    assertEquals(Affinity.EXCELLENT, pairing.getAffinity());
    assertEquals("Chicken", pairing.getFirst().getName());
    assertEquals("Carrot", pairing.getSecond().getName());

    Ingredient carrot = ingredientRepository.findByName("Carrot").iterator().next();
    assertEquals(1, carrot.getPairings().size());
    assertEquals(Affinity.EXCELLENT, pairing.getAffinity());
    assertEquals("Chicken", pairing.getFirst().getName());
    assertEquals("Carrot", pairing.getSecond().getName());
  }
  @Test
  public void checkGettingIngsofCake() {

    cManager.removeAll();
    iManager.removeAll();
    rManager.removeAll();

    Cake cake = new Cake(CAKE_NAME, CAKE_PRICE, CAKE_WEIGHT);
    cManager.addCake(cake);
    cake = cManager.getAll().get(0);

    int i = 0;
    for (String n : ING_NAMES) {
      Ingredient ing = new Ingredient(n, ING_KINDS.get(i));
      iManager.addIngredient(ing);
      i++;
    }
    List<Ingredient> ings = iManager.getAll();

    for (Ingredient ing : ings) rManager.addRelationship(cake, ing);

    List<Ingredient> ingsOfCake = rManager.getIngdredientsOfCake(cake);

    i = 0;
    for (Ingredient ing : ingsOfCake) {
      assertEquals(ING_NAMES.get(i), ing.getName());
      assertEquals(ING_KINDS.get(i), ing.getKind());
      i++;
    }
  }
 @Override
 public float getTotalMenuPrice() {
   /*double counter = 0;
   Set<Ingredient> priceIngredients = getAllIngredients();
   if(priceIngredients != null && !priceIngredients.isEmpty()) {
   	Iterator<Ingredient> iterator = priceIngredients.iterator();
   	while (iterator.hasNext()) {
   		Ingredient ingredient = iterator.next();
   		counter = counter + ingredient.getPrice();
   		System.out.println(counter);
   	}
   	float totalPrice = (float) counter;
   	return totalPrice;
   }
   return 0;*/
   double totalPrice = 0.0;
   if (fullMenu != null) {
     for (Dish menus : fullMenu) {
       Set<Ingredient> ingredients = menus.getIngredients();
       for (Ingredient ingredient : ingredients) {
         totalPrice += ingredient.getPrice();
       }
     }
   }
   return (float) totalPrice;
 }
示例#4
0
  public String getAllIngredients() {
    String s = "";
    for (Ingredient temp : ingredients) {
      s += temp.getName() + "\n";
    }

    return s;
  }
示例#5
0
 public Ingredient getIngredientByName(String name) {
   for (Ingredient temp : allIngredients) {
     if (temp.getName().equalsIgnoreCase(name)) {
       return temp;
     }
   }
   return null;
 }
示例#6
0
 public Recipe() {
   random = new Random();
   ingredient1 = new Ingredient((char) (65 + random.nextInt(5)));
   ingredient2 = new Ingredient((char) (65 + random.nextInt(5)));
   while (ingredient2.equals(ingredient1))
     ingredient2 = new Ingredient((char) (65 + random.nextInt(5)));
   cookingTime = 2000 + random.nextInt(10000);
   ingredient1.setQuantity(2 + random.nextInt(9));
   ingredient2.setQuantity(2 + random.nextInt(9));
 }
 public double getIndividualItemCost(Dish dish) {
   double price = 0.0;
   if (dish != null) {
     Set<Ingredient> ingredients = dish.getIngredients();
     for (Ingredient ingredient : ingredients) {
       price += ingredient.getPrice();
     }
   }
   return price;
 }
 @Test
 public void shouldFetchAllIngredients() {
   Iterable<Ingredient> ingredients = flavorController.getIngredients();
   assertNotNull(ingredients);
   Map<String, Ingredient> ing = new HashMap<>();
   for (Ingredient ingredient : ingredients) {
     ing.put(ingredient.getName(), ingredient);
   }
   assertEquals(5, ing.size());
   assertEquals(ingredientRepository.findByName("Chicken").iterator().next(), ing.get("Chicken"));
   assertEquals(ingredientRepository.findByName("Carrot").iterator().next(), ing.get("Carrot"));
   assertEquals(ingredientRepository.findByName("Butter").iterator().next(), ing.get("Butter"));
   assertEquals(
       ingredientRepository.findByName("Coriander").iterator().next(), ing.get("Coriander"));
   assertEquals(ingredientRepository.findByName("Yoghurt").iterator().next(), ing.get("Yoghurt"));
 }
示例#9
0
 public void deleteIngredient(Ingredient ingredient) {
   mDatabase.delete(
       DbSchema.IngredientTable.NAME,
       DbSchema.IngredientTable.Cols.INGREDIENT_ID
           + " = "
           + "\""
           + ingredient.getIngredientId()
           + "\"",
       null);
 }
  @Before
  public void setup() {
    // Create some ingredients and categories
    Category meat = new Category("Meat");
    Category dairy = new Category("Dairy");
    Category veg = new Category("Vegetable");
    categoryRepository.save(Arrays.asList(meat, dairy, veg));

    Ingredient chicken = new Ingredient("Chicken");
    chicken.setCategory(meat);
    Ingredient carrot = new Ingredient("Carrot");
    carrot.setCategory(veg);
    Ingredient butter = new Ingredient("Butter");
    butter.setCategory(dairy);
    Ingredient coriander = new Ingredient("Coriander");
    coriander.setCategory(veg);
    Ingredient yoghurt = new Ingredient("Yoghurt");
    yoghurt.setCategory(dairy);
    ingredientRepository.save(Arrays.asList(chicken, carrot, butter, yoghurt, coriander));
  }
  /**
   * Function that is called when the user clicks the add ingredient button. Adds the ingredient to
   * the recipe. Also refreshes the view to show the new ingredient.
   */
  public void onAdd() {
    EditText quantity = (EditText) findViewById(R.id.addIngredientQuantity);
    EditText name = (EditText) findViewById(R.id.addIngredientName);
    Spinner units = (Spinner) findViewById(R.id.addIngredientMeasurement);

    // Get the units the user inputed
    int position = units.getSelectedItemPosition();
    String unitsString = Constants.getUnitFromPosition(position);
    String nameString = name.getText().toString();
    String quantityString = quantity.getText().toString();

    // Do the integer conversion like this just in case no number is entered
    Integer amount;
    try {
      amount = new Integer(quantityString);
    } catch (NumberFormatException e) {
      showMessage("Invalid number");
      return;
    }

    Ingredient ingredient = new Ingredient(nameString, amount, unitsString);

    // Check for ingredient validity
    if (ingredient.isValidInfo() != Constants.GOOD) {
      showMessage("Invalid info entered");
      return;
    }

    GlobalApplication app = (GlobalApplication) getApplication();
    Pantry pantry = app.getCurrentRecipe().getIngredients();
    pantry.addIngredient(ingredient);

    // Clear the edit text boxes for future ingredients
    name.setText("");
    quantity.setText("");

    refresh();

    return;
  }
  private void addIngredientButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_addIngredientButtonActionPerformed
    // nastavenie premennych pre ingredienciu
    String name = nameTextField.getText();
    int protein = (int) proteinSpinner.getValue();
    int fat = (int) fatSpinner.getValue();
    int carb = (int) carbSpinner.getValue();
    // validacia mena
    if (name.trim().isEmpty()) {
      JOptionPane.showMessageDialog(this, "You have to fill name field.");
    }
    // ak presli premenne validacou, tak sa nastavia ingrediencii
    ingredient.setName(name);
    ingredient.setProtein(protein);
    ingredient.setFat(fat);
    ingredient.setCarb(carb);
    // prida sa nova ingrediencia do databazy
    ingredientDao.addIngredient(ingredient);

    JOptionPane.showMessageDialog(this, "You have successfully added a new ingredient!");

    this.setVisible(false);
  } // GEN-LAST:event_addIngredientButtonActionPerformed
示例#13
0
 private Ingredient getIngredientWithCursor(Cursor c) {
   Ingredient ingredient = new Ingredient();
   ingredient.setIngredientId(
       c.getString(c.getColumnIndex(DbSchema.IngredientTable.Cols.INGREDIENT_ID)));
   ingredient.setMealId(c.getString(c.getColumnIndex(DbSchema.IngredientTable.Cols.MEAL_ID)));
   ingredient.setName(c.getString(c.getColumnIndex(DbSchema.IngredientTable.Cols.NAME)));
   ingredient.setAmount(
       Double.parseDouble(c.getString(c.getColumnIndex(DbSchema.IngredientTable.Cols.AMOUNT))));
   ingredient.setUnits(c.getString(c.getColumnIndex(DbSchema.IngredientTable.Cols.UNIT)));
   return ingredient;
 }
示例#14
0
  /**
   * Inserts TestData in the database.
   *
   * @return 0
   */
  public static int insertTestData() {
    Uri myBarUri = null;

    // Drinks uses autoincrement in the _id field.
    Drink[] testDrinks = {
      new Drink(
          1,
          "Margarita",
          DEFAULT_URL,
          "Martini Glass",
          DEFAULT_INGREDIENTS,
          "Margarita instructions",
          DEFAULT_RATING,
          DEFAULT_FAVORITE),
      new Drink(
          2,
          "Tequila",
          DEFAULT_URL,
          "Shot Glass",
          DEFAULT_INGREDIENTS,
          "Pour Tequila in shot glass",
          DEFAULT_RATING,
          DEFAULT_FAVORITE),
      new Drink(
          3,
          "Cosmopolitan",
          DEFAULT_URL,
          "Martini Glass",
          DEFAULT_INGREDIENTS,
          "Cosmopolitan instructions",
          DEFAULT_RATING,
          DEFAULT_FAVORITE),
      new Drink(
          4,
          "Cuba Libre",
          DEFAULT_URL,
          "Highball Glass",
          DEFAULT_INGREDIENTS,
          "Cuba Libre instructions",
          DEFAULT_RATING,
          DEFAULT_FAVORITE),
      new Drink(
          5,
          "Martini",
          DEFAULT_URL,
          "Martini Glass",
          DEFAULT_INGREDIENTS,
          "Pour Martini in glass",
          DEFAULT_RATING,
          DEFAULT_FAVORITE),
      new Drink(
          6,
          "Irish Coffee",
          DEFAULT_URL,
          "Coffee Glass",
          DEFAULT_INGREDIENTS,
          "Irish Coffee instructions",
          DEFAULT_RATING,
          DEFAULT_FAVORITE)
    };

    // Insert testDrinks.
    for (Drink testDrink : testDrinks) {
      ContentValues values = testDrink.getContentValues();
      myBarUri =
          MyBarApplication.contentResolver().insert(MyBarContentProvider.CONTENTURI_DRINK, values);
      Log.d(Data.class.getClass().getName(), "Inserted Drink. Created row: " + myBarUri.toString());
    }

    // No autoincrement in Ingredients. Set the _id field manually.
    Ingredient[] testIngredients = {
      new Ingredient(
          1, "Koskenkorva Vodka", DEFAULT_URL, "Vodka", 40, DEFAULT_INGREDIENT_DESCRIPTION),
      new Ingredient(2, "Baileys", DEFAULT_URL, "Liqueur", 20, DEFAULT_INGREDIENT_DESCRIPTION),
      new Ingredient(3, "Dark Rum", DEFAULT_URL, "Rum", 40, DEFAULT_INGREDIENT_DESCRIPTION),
      new Ingredient(4, "Light Rum", DEFAULT_URL, "Rum", 40, DEFAULT_INGREDIENT_DESCRIPTION),
      new Ingredient(5, "Gordon's Gin", DEFAULT_URL, "Gin", 40, DEFAULT_INGREDIENT_DESCRIPTION)
    };

    // Insert testIngredients.
    for (Ingredient testIngredient : testIngredients) {
      ContentValues values = testIngredient.getContentValues();
      myBarUri =
          MyBarApplication.contentResolver()
              .insert(MyBarContentProvider.CONTENTURI_INGREDIENT, values);
      Log.d(
          Data.class.getClass().getName(),
          "Inserted Ingredient. Created row: " + myBarUri.toString());
    }
    return 0;
  }
示例#15
0
  public String toString() {
    String str = "";

    str +=
        "Name: "
            + mName
            + "\n"
            + "Yield: "
            + mYield.getValue()
            + " "
            + mYield.getUnit()
            + "\n"
            + "Prep time: "
            + mPrepTime
            + "\n"
            + "Cook time: "
            + mCookTime
            + "\n"
            + "Overall time: "
            + mOverallTime
            + "\n"
            + "Ingredients list: \n";

    // Iterate through the ingredients
    Vector<MeasurementAndIngredient> measAndIngs = mIngredients.getIngredients();

    MeasurementAndIngredient curMeasAndIng;
    Measurement curMeas;
    Measurement curMeas2;
    Ingredient curIng;
    for (int i = 0; i < measAndIngs.size(); i++) {
      curMeasAndIng = measAndIngs.get(i);
      curMeas = curMeasAndIng.getMeasurement();
      curMeas2 = curMeasAndIng.getMeasurement2();
      curIng = curMeasAndIng.getIngredient();
      str += i + ") ";
      if (curMeas != null) {
        str +=
            "Measurment = "
                + curMeas.getAmount()
                + " "
                + curMeas.getSpecifier()
                + " "
                + curMeas.getUnit();
      }
      if (curMeas2 != null) {
        str +=
            "Measurment 2 = "
                + curMeas2.getAmount()
                + " "
                + curMeas2.getSpecifier()
                + " "
                + curMeas2.getUnit();
      }
      if (curIng != null) {
        str += "    Ingredient = " + curIng.getName();
        String specDir = curIng.getSpecialDirections();
        if (specDir != null && !specDir.equals("")) {
          if (specDir.charAt(0) == ',') {
            str += curIng.getSpecialDirections();
          } else {
            str += " " + curIng.getSpecialDirections();
          }
        }
        str += "\n";
      }
    }

    // Cool! All that's left is directions.
    str += "Directions: \n" + mDirections;

    // Return that new string.
    return str;
  }
示例#16
0
  public static void main(String[] args) {
    long start = System.currentTimeMillis();

    ConversionFactor cupToPint = new ConversionFactor("cup", "pint", 0.50721);
    ConversionFactor pintToCup = new ConversionFactor("pint", "cup", 1.97157);
    Ingredient milk = new Ingredient(2.0, "cup", "milk");
    Ingredient wine = new Ingredient(750.0, "milliliter", "wine");
    Ingredient pinotNoir = new Ingredient(750.0, "ml", "wine");
    Ingredient dietCoke = new Ingredient(0.5, "L", "diet coke");
    Ingredient bakingSoda = new Ingredient(1.5, "teaspoon", "baking soda");
    Ingredient vanilla = new Ingredient(1.0, "tablespoon", "vanilla");
    Ingredient beer = new Ingredient(1.0, "pt", "beer");
    Ingredient buttermilk = new Ingredient(0.25, "qt", "buttermilk");
    Ingredient coffee = new Ingredient(16.0, "ounce", "coffee");

    // Test Cases For Conversion Factor
    // Test Case 1
    testCase(testRightUnitCorrect(cupToPint));
    // Test Case 2
    testCase(testRightUnitCorrect(pintToCup));
    // Test Case 3
    testCase(testRightUnitIncorrect(cupToPint));
    // Test Case 4
    testCase(testRightUnitIncorrect(pintToCup));
    // Test Cases for Ingredient
    // Test Case 5
    testCase(testStandardizeUnit(milk, "cup"));
    // Test Case 6
    testCase(testStandardizeUnit(beer, "pint"));
    // Test Case 7
    testCase(testStandardizeUnit(dietCoke, "liter"));
    // Test Case 8
    testCase(testStandardizeUnit(wine, "ml"));
    // Test Case 9
    testCase(testStandardizeUnit(bakingSoda, "tsp"));
    // Test Case 10
    testCase(testStandardizeUnit(vanilla, "tbsp"));
    // Test Case 11
    testCase(testStandardizeUnit(buttermilk, "quart"));
    // Test Case 12
    testCase(testStandardizeUnit(coffee, "oz"));
    // Test Case 13
    testCase(testConvertIngredientPass(milk, cupToPint));
    // Test Case 14
    testCase(testConvertIngredientFail(dietCoke, cupToPint));
    // Test Case 15
    testCase(testEquals(milk, milk));
    // Test Case 16
    testCase(testNotEquals(milk, buttermilk));
    // Test Case 17
    testCase(testEquals(wine, pinotNoir));

    List<Ingredient> ingredientList = new LinkedList<>();
    ingredientList.add(milk);
    ingredientList.add(wine);
    ingredientList.add(dietCoke);
    ingredientList.add(bakingSoda);
    ingredientList.add(vanilla);
    ingredientList.add(beer);
    ingredientList.add(buttermilk);
    ingredientList.add(coffee);
    Recipe junk = new Recipe(ingredientList, "junk");

    List<Ingredient> doubledIngredientList = new LinkedList<>();
    for (Ingredient ingredient : ingredientList) {
      doubledIngredientList.add(
          new Ingredient(ingredient.getAmount() * 2, ingredient.getUnit(), ingredient.getItem()));
    }
    Recipe junkdoubled = new Recipe(doubledIngredientList, "junk");

    // Testing Recipe class
    // Test Case 18
    testCase(testFindIngredient(milk, junk));
    // Test Case 19
    testCase(testFindIngredient(wine, junk));
    // Test Case 20
    testCase(testFindIngredient(dietCoke, junk));
    // Test Case 21
    testCase(testFindIngredient(bakingSoda, junk));
    // Test Case 22
    testCase(testFindIngredient(vanilla, junk));
    // Test Case 23
    testCase(testFindIngredient(beer, junk));
    // Test Case 24
    testCase(testFindIngredient(buttermilk, junk));
    // Test Case 25
    testCase(testFindIngredient(coffee, junk));
    // Test Case 26
    testCase(testEquals(junk, junk));
    // Test Case 27
    testCase(testNotEquals(junk, junkdoubled));
    // Test Case 28
    testCase(testMultiplyAllAmounts(junk, 2.0, junkdoubled));

    long end = System.currentTimeMillis();
    long timeElapsed = end - start;
    System.out.println(
        Integer.toString(passed) + " out of " + Integer.toString(testsRan) + " tests passed.");
    System.out.println("Time taken:" + Long.toString(timeElapsed) + " millisecond(s).");
  }
示例#17
0
 // Test Cases for the Recipe Class
 public static boolean testFindIngredient(Ingredient ingredient, Recipe recipe) {
   Ingredient ingredientFound = recipe.findIngredient(ingredient.getItem());
   return ingredientFound.equals(ingredient);
 }
示例#18
0
 public static boolean testConvertIngredientFail(
     Ingredient ingredient, ConversionFactor conversionFactor) {
   ingredient.convertIngredient(conversionFactor);
   return !(ingredient.getUnit().equals(conversionFactor.getFrom()));
 }
示例#19
0
 public static boolean testConvertIngredientPass(
     Ingredient ingredient, ConversionFactor conversionFactor) {
   String correctResult = conversionFactor.getTo();
   ingredient.convertIngredient(conversionFactor);
   return ingredient.getUnit().equals(correctResult);
 }
示例#20
0
 // testing methods of Ingredients class
 public static boolean testStandardizeUnit(Ingredient ingredient, String standardUnit) {
   // tests whether you can have a standardized unit
   ingredient.standardizeUnit();
   return ingredient.getUnit().equals(standardUnit);
 }
示例#21
0
 public void mapCustomFieldsSubEntities(EnumLanguage language) {
   this.getTypedish().mapCustomFields(language);
   for (Ingredient ingredient : this.getIngredients()) {
     ingredient.mapCustomFields(language);
   }
 }
  /**
   * scans textfile and returns and ArrayList of Courses
   *
   * @param path - path of the textfile
   * @return ArrayList of Courses
   */
  public void loadCourse(String path) {
    // ArrayList<Course> courseList=new ArrayList<Course>();
    File file = new File(path);

    try {
      Scanner in = new Scanner(file);

      while (in.hasNext()) {
        String line = in.nextLine(); // get line from the txt file
        String[] c = line.split(","); // put the contents into an array

        Boolean courseExists = false;

        if (c.length == 3) {

          c[0] = c[0].toLowerCase().trim(); // set course to lowercase and trim whitespace
          c[1] = c[1].toLowerCase().trim(); // set ingredient to lowercase and trim whitespace
          double unit = Double.parseDouble(c[2]); // get the unit and convert it

          if (!courseList.isEmpty()) { // check if the arraylist is empty

            for (Course course : courseList) { // loop each course ing the course arraylist

              if (course
                  .getName()
                  .equals(
                      c[0])) { // if the course name in the array list is equals to the course in
                // the file
                System.out.println("yes !!!" + c[0] + " exists");

                courseExists = true; // set course exist to true

                int indx = getIngredientIndex(c[1]); // get the index in the arraylist
                if (indx != -1) { // if the ingreient exist ing the course

                  int ingIndx =
                      course.getCourseIngredientIndex(
                          c[1]); // get index of the ingredient in the course
                  if (ingIndx != -1) { // it already exist it
                    // course ingredients

                  } else { // doesnt exist yet
                    course.addIngredient(ingredientList.get(indx), unit);
                  }

                } else { // ingredient doesnt exist
                  System.out.println("Error: ingredient " + c[1] + " doesnt exist");
                  missingIngredientList.add(line.toLowerCase()); // add to missing ingredient
                }

                break; // break loop
              }
            }
          }
          if (!courseExists) {
            System.out.println(c[0] + " it doesnt exist");
            Course cor = new Course();
            cor.setName(c[0]);

            Boolean inExists = false;

            for (Ingredient ing : ingredientList) {
              if (ing.name.equals(c[1])) {
                System.out.println("ingredient exists: " + ing.getName());
                inExists = true;

                cor.addIngredient(ing, unit);

                break;
              }
            }
            if (!inExists) {
              System.out.println("doesnt exist" + c[1]);
              missingIngredientList.add(line.toLowerCase());
            }
            courseList.add(cor);
          }
          // System.out.println(courseList.toString());

        }
      }
      in.close();

    } catch (Exception ex) {
      ex.printStackTrace();
    }
    System.out.println(courseList);
    System.out.println("missing ingredients:");
    for (int i = 0; i < missingIngredientList.size(); i++) {
      System.out.println(missingIngredientList.get(i));
    }

    // return courseList;
  }
 @Override
 public Set<Ingredient> getAllIngredients() {
   boolean ingredientIncluded = false;
   Set<Ingredient> allIngredients = new HashSet<Ingredient>();
   allIngredients.clear();
   if (fullMenu != null && !fullMenu.isEmpty()) {
     for (Dish dish : fullMenu) {
       Set<Ingredient> newIngredients = dish.getIngredients();
       if (newIngredients != null && !newIngredients.isEmpty()) {
         if (allIngredients != null && !allIngredients.isEmpty()) {
           for (Ingredient newIngredient : newIngredients) {
             Iterator<Ingredient> iterator = allIngredients.iterator();
             ingredientIncluded = false;
             while (iterator.hasNext() && ingredientIncluded == false) {
               Ingredient existingIngredient = iterator.next();
               if (existingIngredient.getName().equals(newIngredient.getName())) {
                 existingIngredient.setQuantity(
                     existingIngredient.getQuantity()
                         + newIngredient.getQuantity() * numberOfGuests);
                 existingIngredient.setPrice(
                     existingIngredient.getPrice() + newIngredient.getPrice() * numberOfGuests);
                 allIngredients.remove(existingIngredient);
                 allIngredients.add(
                     new Ingredient(
                         existingIngredient.getName(),
                         existingIngredient.getQuantity(),
                         existingIngredient.getUnit(),
                         existingIngredient.getPrice()));
                 ingredientIncluded = true;
               }
             }
             if (ingredientIncluded == false) {
               allIngredients.add(newIngredient);
             }
           }
         } else {
           Iterator<Ingredient> iterator = newIngredients.iterator();
           while (iterator.hasNext()) {
             Ingredient newIngredient = iterator.next();
             allIngredients.add(
                 new Ingredient(
                     newIngredient.getName(),
                     newIngredient.getQuantity() * numberOfGuests,
                     newIngredient.getUnit(),
                     newIngredient.getPrice() * numberOfGuests));
           }
         }
       }
     }
     return allIngredients;
   }
   return null;
 }
 /**
  * Creates the DishLine object
  *
  * @param ingredient the ingredient
  */
 public DishLine(Ingredient ingredient) {
   this.ingredient.set(ingredient);
   this.amount.set(1);
   total = this.amount.multiply(ingredient.priceProperty());
 }
示例#25
0
 public double getPrice() {
   return price + ingredient.getPrice();
 }