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

Overview: In your final project, you will create a program that will help you ma

ID: 3874651 • Letter: O

Question

Overview: In your final project, you will create a program that will help you manage a collection of recipes. The Recipe class you build for this milestone will hold all the details of the recipe, the methods to create a new recipe, and a method to print a recipe. In your final project submission, this class will also contain a custom method to add a new feature. In your submission for Milestone Two, you will include commented out pseudocode for this method.

Prompt: In this milestone, you submit the final project version of your Recipe class. Your submission should include the Recipe.java file and a Recipe_Test.java file. Your Recipe class should include the following items:

Instance variables: recipeName, servings, recipeIngredients, and totalRecipeCalories

Accessors and mutators for the instance variables

Constructors

A printRecipe() method

A createNewRecipe() method to build a recipe from user input

Pseudocode for the custom method selected from the list in Stepping Stone Lab Five Your Recipe_Test.java file containing a main() method that:

Uses a constructor to create a new recipe

Accesses the printRecipe() method to print the formatted recipe

Invokes the createNewRecipe() method to accept user input

Looking for some feedback. Does my code cover all the requirements above? Also where I would add a custom method to add a new feature.

Recipe file

package SteppingStones;


import java.util.Scanner;

import java.util.ArrayList;

/**
*
*
*
* @author
*
*/
public class Recipe {
  
// Instance variables
private String recipeName;
private int servings;
private double totalRecipeCalories;
private ArrayList<String> recipeIngredients;

/**
* Default no arg constructor
*/
public Recipe() {
this.recipeName = "";
this.servings = 0;
this.recipeIngredients = new ArrayList<>();
this.totalRecipeCalories = 0;
}

/**
* Constructor using fields
*
* @param recipeName
* @param servings
* @param recipeIngredients
* @param totalRecipeCalories
*/
public Recipe(String recipeName, int servings,
ArrayList<String> recipeIngredients, double totalRecipeCalories) {

this.recipeName = recipeName;
this.servings = servings;
this.recipeIngredients = recipeIngredients;
this.totalRecipeCalories = totalRecipeCalories;
}

public void createNewRecipe() {

boolean addMoreIngredients = true;

Scanner scnr = new Scanner(System.in);

System.out.println("Please enter the recipe name: ");

this.recipeName = scnr.nextLine();

System.out.println("Please enter the number of servings: ");

this.servings = scnr.nextInt();

do {

System.out.println("Please enter the ingredient name"
+ " or type end if you are finished entering ingredients: ");

String ingredientName = scnr.next();

if (ingredientName.toLowerCase().equals("end")) {

addMoreIngredients = false;

} else {

this.recipeIngredients.add(ingredientName);

System.out.println("Please enter the ingredient amount: ");

float ingredientAmount = scnr.nextFloat();

System.out.println("Please enter the ingredient Calories: ");

int ingredientCalories = scnr.nextInt();

this.totalRecipeCalories += (ingredientCalories * ingredientAmount);

}

} while (addMoreIngredients);

scnr.close();
}

public void printRecipe() {

int singleServingCalories = (int) (totalRecipeCalories / servings);

System.out.println("Recipe: " + recipeName);

System.out.println("Serves: " + servings);

System.out.println("Ingredients:");

for (String ingredient : recipeIngredients) {

System.out.println(ingredient);

}

System.out.println("Each serving has " + singleServingCalories + " Calories.");

}

public String getRecipeName() {

return recipeName;

}

public void setRecipeName(String recipeName) {

this.recipeName = recipeName;

}

public double getTotalRecipeCalories() {

return totalRecipeCalories;

}

public void setTotalRecipeCalories(double totalRecipeCalories) {

this.totalRecipeCalories = totalRecipeCalories;

}

public ArrayList<String> getRecipeIngredients() {

return recipeIngredients;

}

public void setRecipeIngredients(ArrayList<String> recipeIngredients) {

this.recipeIngredients = recipeIngredients;

}

public int getServings() {

return servings;

}

public void setServings(int servings) {

this.servings = servings;

}

  

}

Recipe Test

*/

/**

*

* @author snhu.edu

*/

public class RecipeTest {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

Recipe recipe1 = new Recipe();

  

recipe1.createNewRecipe();

recipe1.printRecipe();

}

  

}

or this Recipe Test

//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

*/

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 recipeIngredients = new ArrayList();

               ArrayList recipeIngredientsTwo = new ArrayList();

               String ingredientName = "Anchovies";

               Ingredient tempIngredient = new Ingredient().addNewIngredient(ingredientName);

               recipeIngredients.add(tempIngredient);

     

        SteppingStone5_Recipe mySecondRecipe = new SteppingStone5_Recipe("Pizza", 2, recipeIngredients, 300);

       

        // Initialize first recipe

               String ingredientNameTwo = "Noodles";

               Ingredient tempIngredientTwo = new Ingredient().addNewIngredient(ingredientNameTwo);

               recipeIngredientsTwo.add(tempIngredientTwo);

        myFirstRecipe.setRecipeName("Ramen");

        myFirstRecipe.setServings(2);

        myFirstRecipe.setRecipeIngredients(recipeIngredientsTwo);

        myFirstRecipe.setTotalRecipeCalories(150);

       

        // Print details of both recipes

        myFirstRecipe.printRecipe();

        mySecondRecipe.printRecipe();

        }

   

}

Explanation / Answer

Yes, it looks good you have added the required instance variables and setters and getters and required constructors and method to create recipe and to print receipe

Created driver class to take inputs from the user

Write the custom method inside Recipe class only and write the psudo code form  the list in Stepping Stone Lab Five Your

Note: Please comment below if you need any further help on this