Forum Stats

  • 3,741,232 Users
  • 2,248,397 Discussions
  • 7,861,693 Comments

Discussions

Can you help with Erroneous tree type: recipe.Ingredient

User_UAN1W
User_UAN1W Member Posts: 1 Green Ribbon
edited Jul 11, 2021 1:51AM in New To Java

I am new to Java so I don't know how to make sense of the error messages. The following code references things created in another class (Ingredient) so I'm not sure there is enough info here to answer the question.

Line 19 is

ArrayList<Ingredient> recipeIngredients = new ArrayList(); 


package recipe;

import java.util.ArrayList;

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */


public class RecipeTest {

/**

  * @param args the command line arguments

  */

public static void main(String[] args) {

// Create two recipe objects first

Recipe myFirstRecipe = new Recipe();

ArrayList<Ingredient> recipeIngredients = new ArrayList(); 

ArrayList<Ingredient> recipeIngredientsTwo = new ArrayList(); 

String ingredientName = "Anchovies";

Ingredient tempIngredient = new Ingredient().addIngredient(ingredientName);

recipeIngredients.add(tempIngredient);

    

   Recipe mySecondRecipe = new Recipe("Pizza", 2, recipeIngredients, 300);

    

   // Initialize first recipe

String ingredientNameTwo = "Noodles";

Ingredient tempIngredientTwo = new Ingredient().addIngredient(ingredientNameTwo);

recipeIngredientsTwo.add(tempIngredientTwo);


   myFirstRecipe.setRecipeName("Ramen");

   myFirstRecipe.setServings(2);

   myFirstRecipe.setRecipeIngredients(recipeIngredientsTwo);

   myFirstRecipe.setTotalRecipeCalories(150);

    

   // Print details of both recipes

   myFirstRecipe.printRecipe();

   mySecondRecipe.printRecipe();

}

   

}


Sign In or Register to comment.