Attached to this posting is a file named AutomaticKitchen.class. This is a class
ID: 3622831 • Letter: A
Question
Attached to this posting is a file named AutomaticKitchen.class. This is a class that that has the below API. You do NOT have access to the source code of this class.Your assignment:
Write a driver class that simulates a restaurant using AutomaticKitchen.class. You have three tables, one with four people, one with 12 people, and one with 1 person. Everyone at any given table eats the same thing.
Use the AutomatedKitchen in your driver to make and serve a different meal to each table. You can be creative with your ingredients. You might not need to use all the available API methods.
Your deliverables, due by 16 January:
1. Restaurant.java, your correctly commented source code
2. A screen capture or text of the output produced by your Restaurant.java
//AutomatedKitchen API
//define the number of servings this recipe should produce
//defaults to 4
public void setNumberServings(int)
//add an ingredient. Maxium of 10 ingredients may be added. Adding an 11th ingredient will result in the 11th being ignored. Defaults to one ingredient of “water”.
public void setIngredient(String)
//returns the number of ingredients currently added to the kitchen
public int getNumberIngredients()
//sets the cooking temperature. Defaults to 350
public void setCookTemp(int)
//returns the current cooking temperature
public int getCookTemp()
//sets the cooking duration in minutes. Defaults to 30 minutes
public void setCookTime(int)
//returns the currently programmed cooking time
public int getCookTime()
//sets the healthy option. Default is false
public void setHealthyFood(boolean)
//returns the state of the healthy option
public boolean getHealthyOption()
//required to prepare a meal before it’s served.
public void cookMeal()
//returns if a meal is ready to serve. Default is false.
public boolean readyToServe()
//returns a string that is the formatted report of the meal that is served, then sets the object state so that the meal is not ready to serve and must be cooked again.
public String serveMeal()
// end of API
HERE IS THE DRIVER CLASS THAT I HAVE TO USE
001 public class AutomatedKitchen
002 {
003 public final int DEFAULT_NUMBER_SERVINGS = 4;
004 public final int DEFAULT_COOK_TEMP = 350;
005 public final int DEFAULT_COOK_TIME = 30;
006 public final int MAX_INGREDIENTS = 10;
007 private int numberServings;
008 private String[] ingredientList;
009 private int cookTemp;
010 private int cookTime;
011 private boolean healthyFood;
012 private int nextArrayIndex = 0;
013 private String cookedMeal;
014 private boolean mealReady;
015
016 public AutomatedKitchen()
017 {
018 this.numberServings = 4;
019 this.cookTemp = 350;
020 this.cookTime = 30;
021 this.ingredientList = new String[11];
022 this.ingredientList[0] = "water";
023 this.ingredientList[10] = "";
024 }
025
026 public void setNumberServings(int paramInt)
027 {
028 this.numberServings = paramInt;
029 }
030
031 public void setIngredient(String paramString)
032 {
033 if (this.nextArrayIndex < 10) {
034 this.ingredientList[this.nextArrayIndex] = paramString;
035 this.nextArrayIndex += 1;
036 }
037 }
038
039 public int getNumberIngredients()
040 {
041 return this.ingredientList.length;
042 }
043
044 public void setCookTemp(int paramInt)
045 {
046 this.cookTemp = paramInt;
047 }
048
049 public int getCookTemp()
050 {
051 return this.cookTemp;
052 }
053
054 public void setCookTime(int paramInt)
055 {
056 this.cookTime = paramInt;
057 }
058
059 public int getCookTime()
060 {
061 return this.cookTime;
062 }
063
064 public void setHealthyFood(boolean paramBoolean)
065 {
066 this.healthyFood = paramBoolean;
067 }
068
069 public boolean getHealthyFood()
070 {
071 return this.healthyFood;
072 }
073
074 public void cookMeal()
075 {
076 this.mealReady = true;
077 }
078
079 public boolean readyToServe()
080 {
081 return this.mealReady;
082 }
083
084 public String serveMeal()
085 {
086 if (!readyToServe()) {
087 return "This meal is not cooked yet!";
088 }
089
090 if (this.nextArrayIndex == 0) this.ingredientList[10] = this.ingredientList[0];
091 else {
092 for (int i = 0; i < this.nextArrayIndex; i++) {
093 if (i == this.nextArrayIndex - 1) this.ingredientList[10] = (this.ingredientList[10] + "and " + this.ingredientList[i]); else {
094 this.ingredientList[10] = (this.ingredientList[10] + this.ingredientList[i] + ", ");
095 }
096 }
097 }
098 double d = Math.random() * 10.0D;
099 String str1;
100 if (d < 3.0D) str1 = "pretty good";
101 else if (d < 6.0D) str1 = "terrible"; else
102 str1 = "five star delicous";
103 String str2;
104 if (getHealthyFood()) str2 = "healthy"; else str2 = "unhealthy";
105 this.mealReady = false;
106 return "Serving a meal for " + this.numberServings + ". This meal is " + str2 + ". We cooked a blend of " + this.ingredientList[10] + " for " + getCookTime() + " minutes at " + getCookTemp() + " degrees. It's " + str1 + ".";
107 }
108 }
HERE IS WHAT I HAVE FOR MY PROGRAMMING. IT DOESN'T WORK COMPLETELY RIGHT.
public class Restaurant {
public static void main (String[] args) {
AutomatedKitchen Table1 = new AutomatedKitchen();
Table1.setNumberServings(1);
Table1.setIngredient("BBQ'd ribs, potatoe salad, mac&cheese.");
Table1.setCookTemp(400);
Table1.setCookTime(30);
Table1.getNumberIngredients();
Table1.getCookTemp();
Table1.getCookTime();
if(Table1.readyToServe())
Table1.serveMeal();
else
Table1.cookMeal();
System.out.println("~~~~~~~~~~ Table 1 Waiter name is Peter~~~~~~~~~~");
System.out.println(Table1.serveMeal());
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~");
AutomatedKitchen Table2 = new AutomatedKitchen();
Table2.setNumberServings(4);
Table2.setIngredient("cheese sticks, chicken tenders, french fries.");
Table2.setCookTemp(475);
Table2.setCookTime(120);
Table2.getNumberIngredients();
Table2.getCookTemp();
Table2.getCookTime();
if(Table2.readyToServe())
Table2.serveMeal();
else
Table2.cookMeal();
System.out.println("~~~~~~~~~~ Table 2 Waitress name is Jane ~~~~~~~~~~");
System.out.println(Table2.serveMeal());
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~");
AutomatedKitchen Table3 = new AutomatedKitchen();
Table3.setNumberServings(12);
Table3.setIngredient("ham, mashed potatoes, stove top stuffing, with a side of pineapple.");
Table3.setCookTemp(450);
Table3.setCookTime(20);
Table3.getNumberIngredients();
Table3.getCookTemp();
Table3.getCookTime();
if(Table3.readyToServe())
Table3.serveMeal();
else
Table3.cookMeal();
System.out.println("~~~~~~~~~~ Table 3 Waiter name is Java ~~~~~~~~~~");
System.out.println(Table3.serveMeal());
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~");
} // end of main() method
}
Explanation / Answer
please rate - thanks
I believe you should set 1 ingredient at a time
how's this. get back to me if still has a problem
public class Restaurant {
public static void main (String[] args) {
AutomatedKitchen Table1 = new AutomatedKitchen();
Table1.setNumberServings(1);
Table1.setIngredient("BBQ'd ribs");
Table1.setIngredient("potatoe salad");
Table1.setIngredient("mac&cheese");
Table1.setCookTemp(400);
Table1.setCookTime(30);
System.out.println("~~~~~~~~~~ Table 1 Waiter name is Peter~~~~~~~~~~");
System.out.println(Table1.serveMeal());
while(!Table1.readyToServe())
Table1.cookMeal();
System.out.println(Table1.serveMeal());
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~");
AutomatedKitchen Table2 = new AutomatedKitchen();
Table2.setNumberServings(4);
Table2.setIngredient("cheese sticks");
Table2.setIngredient("chicken tenders");
Table2.setIngredient("french fries");
Table2.setCookTemp(475);
Table2.setCookTime(120);
System.out.println("~~~~~~~~~~ Table 2 Waitress name is Jane ~~~~~~~~~~");
System.out.println(Table2.serveMeal());
while(!Table2.readyToServe())
{Table2.cookMeal();
}
System.out.println(Table2.serveMeal());
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~");
AutomatedKitchen Table3 = new AutomatedKitchen();
Table3.setNumberServings(12);
Table3.setIngredient("ham");
Table3.setIngredient("mashed potatoes");
Table3.setIngredient("stove top stuffing");
Table3.setIngredient("side of pineapple");
Table3.setCookTemp(450);
Table3.setCookTime(20);
System.out.println("~~~~~~~~~~ Table 3 Waiter name is Java ~~~~~~~~~~");
System.out.println(Table3.serveMeal());
while(!Table3.readyToServe())
Table3.cookMeal();
System.out.println(Table3.serveMeal());
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~");
} // end of main() method
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.