Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with this project. The requirements are: Developing your own driver class including custom methods to access elements of the Ingredient and Recipe classes.

Need help with this project. The requirements are:

Developing your own driver class including custom methods to access elements of the Ingredient and Recipe classes.

Specifically, you will need to create the following:

The instance variables for the class (listOfRecipes)

Accessors and mutators for the instance variable

Constructors

Three custom methods: printAllRecipeDetails(), printAllRecipeNames, and addNewRecipe

/*

* 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.

*/

package SteppingStones;

import java.util.ArrayList;

/**

*

* @author snhu.edu

*/

public class SteppingStone6_RecipeBox {

/**

* Declare instance variables:

* a private ArrayList of the type SteppingStone5_Recipe named listOfRecipes

*

*/

/**

* Add accessor and mutator for listOfRecipes

*

*/

/**

* Add constructors for the SteppingStone6_RecipeBox()

*

*/

/**

* Add the following custom methods:

*

* //printAllRecipeDetails(SteppingStone5_Recipe selectedRecipe)

* This method should accept a recipe from the listOfRecipes ArrayList

* recipeName and use the SteppingStone5_Recipe.printRecipe() method

* to print the recipe

*

* //printAllRecipeNames() <-- This method should print just the recipe

* names of each of the recipes in the listOfRecipes ArrayList

*

* //addRecipe(SteppingStone5_Recipe tmpRecipe) <-- This method should use

* the SteppingStone5_Recipe.addRecipe() method to add a new

* SteppingStone5_Recipe to the listOfRecipes

*

*/

/**

* A variation of following menu method should be used as the actual main

* once you are ready to submit your final application. For this

* submission and for using it to do stand-alone tests, replace the

* public void menu() with the standard

* public static main(String[] args)

* method

*

*/

public void menu() {

// Create a Recipe Box

//SteppingStone6_RecipeBox myRecipeBox = new SteppingStone6_RecipeBox(); //Uncomment for main method

Scanner menuScnr = new Scanner(System.in);

/**

* Print a menu for the user to select one of the three options:

*

*/

System.out.println("Menu " + "1. Add Recipe " + "2. Print All Recipe Details " + "3. Print All Recipe Names " + " Please select a menu item:");

while (menuScnr.hasNextInt() || menuScnr.hasNextLine()) {

System.out.println("Menu " + "1. Add Recipe " + "2. Print All Recipe Details " + "3. Print All Recipe Names " + " Please select a menu item:");

int input = menuScnr.nextInt();

/**

* The code below has two variations:

* 1. Code used with the SteppingStone6_RecipeBox_tester.

* 2. Code used with the public static main() method

*

* One of the sections should be commented out depending on the use.

*/

/**

* This could should remain uncommented when using the

* SteppingStone6_RecipeBox_tester.

*

* Comment out this section when using the

* public static main() method

*/

if (input == 1) {

newRecipe();

} else if (input == 2) {

System.out.println("Which recipe? ");

String selectedRecipeName = menuScnr.next();

printAllRecipeDetails(selectedRecipeName);

} else if (input == 3) {

for (int j = 0; j < listOfRecipes.size(); j++) {

System.out.println((j + 1) + ": " + listOfRecipes.get(j).getRecipeName());

}

} else {

System.out.println(" Menu " + "1. Add Recipe " + "2. Print Recipe " + "3. Adjust Recipe Servings " + " Please select a menu item:");

}

/**

* This could should be uncommented when using the

* public static main() method

*

* Comment out this section when using the

* SteppingStone6_RecipeBox_tester.

*

if (input == 1) {

myRecipeBox.newRecipe();

} else if (input == 2) {

System.out.println("Which recipe? ");

String selectedRecipeName = menuScnr.next();

myRecipesBox.printAllRecipeDetails(selectedRecipeName);

} else if (input == 3) {

for (int j = 0; j < myRecipesBox.listOfRecipes.size(); j++) {

System.out.println((j + 1) + ": " + myRecipesBox.listOfRecipes.get(j).getRecipeName());

}

} else {

System.out.println(" Menu " + "1. Add Recipe " + "2. Print Recipe " + "3. Adjust Recipe Servings " + " Please select a menu item:");

}

*

*/

System.out.println("Menu " + "1. Add Recipe " + "2. Print All Recipe Details " + "3. Print All Recipe Names " + " Please select a menu item:");

}

}

}

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_2

Step: 3

blur-text-image_3

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

Genomes And Databases On The Internet A Practical Guide To Functions And Applications

Authors: Paul Rangel

1st Edition

189848631X, 978-1898486312

More Books

Students also viewed these Databases questions