Question
Good morning - can I have a tutor check my work based off of the instructions below? I am not sure if I have done
Good morning - can I have a tutor check my work based off of the instructions below? I am not sure if I have done it correctly or not. And if I have not, can someone please assist with my code? I think the requirements states I need a print function as well? I would greatly appreciate it!!! I will post my code output results below after it has been ran. I am not sure if my code needs cleaned up or is missing anything.
IT 511 Milestone Two Guidelines and Rubric The Recipe Class
****************************************Instructions*******************************************
"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"
Code -
***************************Ingredient****************************
package Recipe;
import java.util.Scanner;
import java.util.ArrayList;
/** * * @author rbell */ class Recipe {
private String recipeName; private int servings; ArrayList
/** * * @param recipeName */ public void setRecipeName(String recipeName) { this.recipeName = recipeName; }
/** * * @return */ public String getRecipeName() { return recipeName; }
/** * * @param servings */ public void setServings(int servings) { this.servings = servings; }
/** * * @return */ public int getServings() { return servings; }
/** * * @param recipeIngredients */ public void setRecipeIngredients(ArrayList
/** * * @return */ public ArrayList
/** * * @param totalRecipeCalories */ public void setTotalRecipeCalories(int totalRecipeCalories) { this.totalRecipeCalories = totalRecipeCalories; }
/** * * @return */ public int getTotalRecipeCalories() { return totalRecipeCalories; }
/* Constructors to use for preset fields */
public Recipe() { this.recipeName = ""; this.servings = 0; this.recipeIngredients = new ArrayList
/** * * @param recipeName * @param servings * @param recipeIngredients * @param totalRecipeCalories */ public Recipe(String recipeName, int servings, ArrayList
/* Method used to Print the Recipe Details */
public void printRecipe() { int singleServingCalories = (totalRecipeCalories / servings); System.out.println(" Recipe: " + recipeName); System.out.println("Serves: " + servings); System.out.println("Ingredients: "); for (int i = 0; i < recipeIngredients.size(); i++) { String ingredient = recipeIngredients.get(i); System.out.println(ingredient); } System.out.println("Each Serving Has " + singleServingCalories + " Calories."); } //Method to create a New Recipe so that you can Build Recipes Based on the User's Input
/** * * @param args * @return */
public Recipe addNewRecipe() { //bint totalRecipeCalories = 0; ArrayList
***************************IngredientTest*********************************
package Recipe;
/** * * @author rbell */ public class RecipeTest {
/** * @param args the command line arguments */ public static void main(String[] args) { final Recipe newRecipe = new Recipe(); //Constructor used to create the new Recipe newRecipe.addNewRecipe(); //Invoke function to addNewRecipe() newRecipe.printRecipe(); //Access used to printRecipe() } }
****Code after it is ran****
run: Please enter the recipe name: pizza Please enter the number of servings: 2 Please enter the ingredient name or type 'end' if you are finished entering ingredients: flour Please enter the number of units of the ingredient to be used: 3 Please enter the ingredient Calories per unit: 44 Please enter the ingredient name or type 'end' if you are finished entering ingredients: end
Recipe: pizza Serves: 2 Ingredients: flour Each Serving Has 66 Calories.
Recipe: Serves: 2 Ingredients: Each Serving Has 66 Calories. BUILD SUCCESSFUL (total time: 17 seconds)
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