Question: Copy and pasteable code below same as above for your convenience. Thanks a lot! package code; /** * You are given a partial definition of


Copy and pasteable code below same as above for your convenience. Thanks a lot!
package code;
/**
* You are given a partial definition of a Recipe class. Your task is to complete this class by
* writing a constructor and 3 getter methods for the 3 instance variables
*/
public class Recipe {
// Do not edit these variables
private String name;
private String ingredientOne;
private String ingredientTwo;
// 15 Competency Points
// Write a public constructor for the Recipe class that takes 3 Strings as parameters. In the constructor, set
// the first parameter to the name instance variable, the second to ingredientOne, and the third to
// ingredientTwo
public Recipe(String a, String b, String c){
this. name = a;
this. ingredientOne = b;
this. ingredientTwo = c;
}
// 15 Competency Points
// Write a public method named getName that doesn't take any parameters and has return type String. This
// method should return the value of the name instance variable
public String getName(){
return name;
}
// 15 Competency Points
// Write a public method named getIngredientOne that doesn't take any parameters and has return type String. This
// method should return the value of the ingredientOne instance variable
public String getIngredientOne(){
return ingredientOne;
}
// 15 Competency Points
// Write a public method named getIngredientTwo that doesn't take any parameters and has return type String. This
// method should return the value of the ingredientTwo instance variable
public String getIngredientTwo(){
return ingredientTwo;
}
}
package code;
import java.util.ArrayList;
/**
* You are given an empty Kitchen class that will be written entirely by you. You will write an instance
* variable, a constructor, and several methods in this class.
*
* It is recommended that you start with the Recipe class.
*/
public class Kitchen {
private static final String String = null;
// 15 Competency Points
// Create a private instance variable with type ArrayList of String named ingredients
private ArrayList
// 15 Competency Points
// Write a public constructor that doesn't take any parameters and initializes the ingredients variable
// to a new ArrayList
public void donttake(){
ArrayList
}
// 15 Competency Points
// Write a public method named addIngredient that takes one String as a parameter and has return type void.
// This method will add the input String to the ingredients ArrayList
public void addIngredients(String a){
this.ingredients.add(a);
}
// 15 Competency Points
// Write a public method named removeIngredient that takes one String as a parameter and has return type void.
// This method will remove one instance of the input String from the ingredients ArrayList.
// If the input is not in the ArrayList this method will have no effect
// Hint: The ArrayList class has a remove method
// 15 Competency Points
// Write a public method named containsIngredient that takes one String as a parameter and has return type boolean.
// This method will return true if the input String is in the ingredients ArrayList and false if it is not
public boolean containsIngredients(String a){
if(this.ingredients.contains(ingredients)){
return true;
}
return false;
}
// 15 Competency Points
// Write a public method named getQuantity that doesn't take any parameters and has return type int.
// This method will return the total number of ingredients in this kitchen
public int getQuantity(){
return this.ingredients.size();
}
// 1 Proficiency Point (Due 24 hours after the end of lab)
// Write a public method named canCook that takes a Recipe as a parameter and has return type boolean.
// This method will true if this Kitchen contains both ingredients in the recipe, false otherwise
// 1 Proficiency Point (Due 24 hours after the end of lab)
// Write a public method named cook that takes a Recipe as a parameter and has return type void.
// If the recipe can be cooked, this method will remove one of each of the ingredients in the recipe.
// If the recipe can not be cooked, this method will have no effect.
}
Kitchen,java Recipe.java 3 1 package code; 4 You are given a partial definition of a Recipe class. Your task is to complete this class by 5writing a constructor and 3 getter methods for the 3 instance variables 7 public class Recipe // Do not edit these variables private String name; private String ingredient0ne; private String ingredientTwo; /15 Competency Points // Write a public constructor for the Recipe class that takes 3 Strings as paraneters. In the constructor, set // the first parameter to the name instance variable, the second to ingredientOne, and the third to I/ ingredientTwo 10 13 14 15 16 17 18 public Recipe(String a, String b, String c this. name a; this. ingredientOneb this. ingredientTwo c; 21 15 Competensy Points // Write a public method named getName that doesn't take any parameters and has return type String. This // method should return the value of the name instance variable e public String getNameO return name; 29 30 31 32 public String getIngredientOne /15 Competency Points /I Write a public method named getIngredientOne that doesn't take any parameters and has return type String. This // method should return the value of the ingredientOne instance variable return ingredientOne; 35 37 39 / method should return the value of the ingredientTwo instance variable 15 Competency Points // Write a public method named getIngredientTwo that doesn't take any parameters and has return type String. This 40 public String getIngredientTwoO return ingredientTwo; 45
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
