I hope this function gives you a raw idea on how it might work:
// a couple of items to help out with the imagination
Item apple = new Item("Apple");
Item sugar = new Item("Sugar");
Item peach = new Item("Peach");
Item marmelade = new Item("Marmelade");
Item banana= new Item("Banana");
Item milk= new Item("Milk");
Item shake = new Item("Banana Shake");
// as an example: 2 recipes for better imagination
Item[] marmeladeRecipe= {apple, peach, sugar, marmelade};
Item[] shakeRecipe = {banana, milk, sugar, shake};
// a list of all the recipes you have
ArrayList<Item[]> baseRecipes = new ArrayList<Item[]>();
// now add the recipes to your list
baseRecipes.add(marmeladeRecipe);
baseRecipes.add(shakeRecipe);
You can now create separate methods and check for each element one after another like you mentioned in your comment below. Exemplatory for the first item it looks like this and should be anologue for the other two indices:
// this is for the 1. element or 0th index
ArrayList<Item[]> getRecipesForFirst(Item item, ArrayList<Item> allRecipes) {
// a list of recipes with all item as the first element
ArrayList<Item[]> recipes = new ArrayList<Item>();
// for each recipe in the list of all recipes...
for(Item[] recipe in allRecipes) {
// only adds recipe from the allRecipes list to the recipes list
// if item matches the first entry
if(recipe[0].equals(item)) {
recipes.add(recipe);
}
}
return recipes;
}
One more thing to keep in mind and which I edited is that you have to give the method a new ArrayList because otherwise you would get messy results.
Furthermore, this does not return a boolean which you demanded but you can simply check that when invoking the method:
// I created a made up item for better imagination
ArrayList<Item> recipesForFirst = getRecipesForFirst(banana, baseRecipes);
// equivalent to your demanded boolean
if(!recipesForFirst.isEmpty()) {
// loop is needed because there might be multiple recipes
for(Item[] recipe : recipesForFirst) {
// create a new list that now checks for second item but
// only in recipes that have the first item
ArrayList<Item> recipesForSecond = getRecipesForSecond(recipe[1], recipesForFirst);
if(!recipesForSecond.isEmpty()) {
for(Item[] reci : recipesForSecond) {
ArrayList<Item> recipesForThird = getRecipesForThird(reci[2], recipesForSecond);
if(!getRecipesForThird.isEmpty()) {
for(Item[] r : recipesForThird) {
// do something
}
}
}
}
}
}