Question: 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
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. 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. Specifics Here is the code so far that I've done for the Recipe Class
/* * 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 recipe.collection;
import java.util.ArrayList; import java.util.Scanner;
public class Recipe { private String recipeName; private int serving; private ArrayListrecipeIngredients; private double totalRecipeCalories; public Recipe() { this.recipeName = ""; this.serving = 0; //<--- assignment value with appropriate data type this.recipeIngredients = new ArrayList(); //<-- assignment value for empty ArrayList this.totalRecipeCalories = 0; } //accessor that retrieves the recipe name public String getRecipeName() { return recipeName; } //mutator that sets the recipe name public void setRecipeName(String recipeName){ this.recipeName = recipeName; } //accessor to retrieve the serving size public int getServing() { return serving; } //mutator to set the serving size public void setServing(int serving) { this.serving = serving; } // calls the Array that holds the recipe ingredients public ArrayList getRecipeIngredients() { return recipeIngredients; } //sets the ingredients held by the array public void setRecipeIngredients(ArrayList recipeIngredients){ this.recipeIngredients = recipeIngredients; } //accessor that calls the total recipe calories public double getTotalRecipeCalories(){ return totalRecipeCalories; } //mutator that sets the total recipe calories public void setTotalRecipeCalories(double totalRecipeCalories){ this.totalRecipeCalories = totalRecipeCalories; } //Recipe class public Recipe(String recipeName, int servings, ArrayList recipeIngredients, double totalRecipeCalories) //<-- use appropriate data type for the ArrayList and the servings arguments { this.recipeName = recipeName; this.serving = serving; this.recipeIngredients = recipeIngredients; this.totalRecipeCalories = totalRecipeCalories; } public void printRecipe() { int singleServingCalories = (int) totalRecipeCalories / serving; System.out.println("Recipe:" + recipeName + " Serves: " + serving + " Ingredients: "); for (int i = 0; i < recipeIngredients.size(); i++) { System.out.print(recipeIngredients.get(i) + " "); } System.out.print(".Each serving has " + singleServingCalories + " calories"); } public static void main(String[] args) { double totalRecipeCalories = 0; ArrayList recipeIngredients = new ArrayList(); boolean addMoreIngredients = true; String reply=""; 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: "); int 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 { 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(); totalRecipeCalories = ingredientCalories * ingredientAmount; System.out.println("Do you want to continue. Y/N"); reply = scnr.nextLine(); } } while (!reply.equals("n")) ; scnr.close(); Recipe recipe1 = new 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 * */