Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Stepping Stone Lab 5 I am including for reference. Stepping Stone Lab 5 I create

ID: 3903622 • Letter: S

Question

Stepping Stone Lab 5 I am including for reference.

Stepping Stone Lab 5 I created a Recipe Class which you can see below. This Lab will focus on developing my own driver class including custom methods to access elements of the ingredient and crecipe classes.

Specifically, I will need to create the following for *Stepping Stone Lab 6*: ? The instance variables for the class (listOfRecipes) ? Accessors and mutators for the instance variable ? Constructors ? Three custom methods: printAllRecipeDetails(), printAllRecipeNames, and addNewRecipe

Stepping Stone Lab 6 is below which i need to complete.

Guidelines for Submission: This assignment should be submitted as a Java file.

Stepping Stone Lab 5:

/*
* 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.Scanner;
import java.util.ArrayList;

/**
*
* @author Eli Mishkit
*/

public class SteppingStone5_Recipe {
  
private String recipeName;
double totalRecipeCalories = 0.0;
ArrayList recipeIngredients = new ArrayList();
boolean addMoreIngredients = true;
int servings;

public String getRecipeName() {
return recipeName;
}

public double getTotalRecipeCalories() {
return totalRecipeCalories;
}

public ArrayList getRecipeIngredients() {
return recipeIngredients;
}

public boolean isAddMoreIngredients() {
return addMoreIngredients;
}

public int getServings() {
return servings;
}

public void setRecipeName(String recipeName) {
this.recipeName = recipeName;
}

public void setTotalRecipeCalories(double totalRecipeCalories) {
this.totalRecipeCalories = totalRecipeCalories;
}

public void setRecipeIngredients(ArrayList recipeIngredients) {
this.recipeIngredients = recipeIngredients;
}

public void setAddMoreIngredients(boolean addMoreIngredients) {
this.addMoreIngredients = addMoreIngredients;
}

public void setServings(int servings) {
this.servings = servings;
}

  
public SteppingStone5_Recipe() {
this.recipeName = "";
this.servings = 0; //<--- assignment value with appropriate data type

this.totalRecipeCalories = 0;
  
}
public SteppingStone5_Recipe(String recipeName, int servings, ArrayList recipeIngredients, double totalRecipeCalories)
//<-- use appropriate data type for the ArrayList and the servings arguments
{
this.recipeName = recipeName;
this.servings = servings;
this.recipeIngredients = recipeIngredients;
this.totalRecipeCalories = totalRecipeCalories;
}
  
public void printRecipe() {
double singleServingCalories;
singleServingCalories = this.totalRecipeCalories/this.servings;
/**
* Print the following recipe information:
* Recipe: <>
system.out.println("Recipe Name" + this.recipeName);
* Serves: <>
* Ingredients:
* <>
* <>
* ...
* <>
*
* Each serving has <> Calories.
*
* HINT --> Use a for loop to iterate through the ingredients
*/
System.out.println("Recipe Name" + this.recipeName);
System.out.println("Serves" + this.servings);
System.out.println("Ingredients");
for(String m:recipeIngredients)
{
System.out.println(m);
}
System.out.println("Each serving has"+ singleServingCalories+ "Calories");
}
  
  
public static void main(String[] args) {
double totalRecipeCalories = 0.0;
ArrayList recipeIngredients = new ArrayList();
boolean addMoreIngredients = true;
  
Scanner scnr = new Scanner(System.in);
  
System.out.println("Please enter the recipe name: ");
String recipeName = scnr.nextLine();
  
System.out.println("Please enter the number of servings: ");
//correct data type & Scanner assignment method for servings variable
int servings = scnr.nextInt();
String ingredientName ;
  
do {
System.out.println("Please enter the ingredient name or type end if you are finished entering ingredients: ");
ingredientName = scnr.next();
if (ingredientName.toLowerCase().equals("end")) {
addMoreIngredients = false;
} else {

/**
* Add the ingredient name to recipeIngredients
*
*/
  
System.out.println("Please enter the ingredient amount: ");
float ingredientAmount = scnr.nextFloat();
  
System.out.println("Please enter the ingredient Calories: ");
int ingredientCalories = scnr.nextInt();
  
/**
* Add the total Calories from this ingredient
* (ingredientCalories * ingredientAmount)
* to the totalRecipeCalories
*
*/
  
}

} while (!ingredientName.equals("n")) ;
  
SteppingStone5_Recipe recipe1 = new SteppingStone5_Recipe(recipeName,servings, recipeIngredients, totalRecipeCalories);
recipe1.printRecipe();
}
}


/**
* Final Project
*
* For your Final Project:
*
* 1. Modify this code to develop a Recipe class:
*   a. change the void main method createNewRecipe() that returns a Recipe
*      
* 2. FOR FINAL SUBMISSION ONLY:Change the ArrayList type to an
*       Ingredient object. When a user adds an ingredient to the recipe,
*        instead of adding just the ingredient name, you will be adding the
*       actual ingredient including name, amount, measurement type, calories.
*   For the Milestone Two submission, the recipeIngredients ArrayList can
*   remain as a String type.
*
* 3. Adapt the printRecipe() method to print the amount and measurement
*    type as well as the ingredient name.
*
* 4. Create a custom method in the Recipe class.
* Choose one of the following options:
*
*    a. print out a recipe with amounts adjusted for a different
*        number of servings
*
*    b. create an additional list or ArrayList that allow users to
*        insert step-by-step recipe instructions
*
*    c. conversion of ingredient amounts from
*        English to metric (or vice versa)
*
*    d. calculate select nutritional information
*
*    e. calculate recipe cost
*
* f. propose a suitable alternative to your instructor
*
*/

Stepping Stone Lab 6:

/*
* 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:");
       }
      
  
   }

}

*** I believe you could have it take just about any arguemetn. I normally just have it take a number, so if you made a nenu selection, you could attach that to a number. So if you made a menu selection of create new ingredient, which i gave a number 1. I find Numbers are easier to compare than strings, so I would suggest we just go with a number.****

Let me know if this helps.

Thanks

Explanation / Answer

import java.util.Scanner; import java.util.ArrayList; /** * * @author Eli Mishkit */ public class SteppingStone5_Recipe { private String recipeName; double totalRecipeCalories = 0.0; ArrayList recipeIngredients = new ArrayList(); boolean addMoreIngredients = true; int servings; public String getRecipeName() { return recipeName; } public double getTotalRecipeCalories() { return totalRecipeCalories; } public ArrayList getRecipeIngredients() { return recipeIngredients; } public boolean isAddMoreIngredients() { return addMoreIngredients; } public int getServings() { return servings; } public void setRecipeName(String recipeName) { this.recipeName = recipeName; } public void setTotalRecipeCalories(double totalRecipeCalories) { this.totalRecipeCalories = totalRecipeCalories; } public void setRecipeIngredients(ArrayList recipeIngredients) { this.recipeIngredients = recipeIngredients; } public void setAddMoreIngredients(boolean addMoreIngredients) { this.addMoreIngredients = addMoreIngredients; } public void setServings(int servings) { this.servings = servings; } public SteppingStone5_Recipe() { this.recipeName = ""; this.servings = 0; //
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote