Question
Please Complete the Following //SteppingStone5_recipeTester.java *To test the functionality of your finished code, use the SteppingStone5_RecipeTest.java file *Replace the public static void main(String[] args)
Please Complete the Following "//SteppingStone5_recipeTester.java"
*To test the functionality of your finished code, use the SteppingStone5_RecipeTest.java file *Replace the public static void main(String[] args) with public SteppingStone5_Recipe createNewRecipe() Guidelines for Submission: This assignment should be submitted as a Java file.
Adding Original File //SteppingStone5_recipe.java" for context.
/* * 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
public String getRecipeName() { return recipeName; }
public double getTotalRecipeCalories() { return totalRecipeCalories; }
public ArrayList
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
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
/** * 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 * */
//SteppingStone5_recipeTester.java
import java.util.ArrayList;
/* * 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;
/** * * @author Eli Mishkit */ public class SteppingStone5_RecipeTest {
/** * @param args the command line arguments */ public static void main(String[] args) { // Create two recipe objects first SteppingStone5_Recipe myFirstRecipe = new SteppingStone5_Recipe(); ArrayList
myFirstRecipe.setRecipeName("Ramen"); myFirstRecipe.setServings(2); myFirstRecipe.setRecipeIngredients(recipeIngredientsTwo); myFirstRecipe.setTotalRecipeCalories(150); // Print details of both recipes myFirstRecipe.printRecipe(); mySecondRecipe.printRecipe(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started