Question: PLEASE SHOW ME WHERE TO INSERT MAIN METHOD (PUBLIC STATIC VOID MAIN STRING ARGS []) SO PROGRAM CAN RUN BELOW, CODE IS SAYING IT DOES

PLEASE SHOW ME WHERE TO INSERT MAIN METHOD (PUBLIC STATIC VOID MAIN STRING ARGS []) SO PROGRAM CAN RUN BELOW, CODE IS SAYING IT DOES NOT HAVE A MAIN METHOD:

import java.util.ArrayList;

/**

* ReciepeBox class :

* collection of recipe

*

*/

public class ReciepeBox {

private ArrayList recipes;

public ReciepeBox() {

this.recipes = new ArrayList<>();

}

//add a Recipe in collection

public void addItem(Recipe recipe){

recipes.add(recipe);

}

//delete a Recipe in collection

public void deleteItem(Recipe recipe){

recipes.remove(recipe);

}

//print all recipes

public void printAllRecipies(){

int i = 0;

for(Recipe rec: recipes){

i++;

System.out.println("Recipe " + i);

rec.printRecipe();

}

}

public static void main(String[] args) {

//create some demo recipes

Recipe recipe1 = Recipe.createNewRecipe("Pizza");

Ingredient ingredient1 = new Ingredient("Anchovies",20,"gram",300);

recipe1.addIngredient(ingredient1);

Recipe recipe2 = Recipe.createNewRecipe("Ramen");

Ingredient ingredient2 = new Ingredient("Noodles",50,"gram",200);

recipe2.addIngredient(ingredient2);

// add in box

ReciepeBox box = new ReciepeBox();

box.addItem(recipe1);

box.addItem(recipe2);

box.printAllRecipies();

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!