Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions

Question

describe the main employment rights as stated in the law

Answered: 1 week ago