Question: In this exercise, we will create two distinct classes, a Meal and a Chef. A Meal consists of three attributes - a name, the number

In this exercise, we will create two distinct classes, a Meal and a Chef.

A Meal consists of three attributes - a name, the number of calories in the meal, and a recipe. The Meal class should include getter methods for all instance variables, and a toString that provides the name and the number of calories that make up the meal. For example, the toString for the meal Meal toast = new Meal("Toast", 100, "Put in toaster for 3 mins"); would return:

Toast, which has 100 calories."

The Chef class also has three instance variables - the chefs name, the name of the restaurant they work at, and their best meal. Their best meal should be a Meal object.

The Chef class should have getter methods for all instance variables, as well as getter methods for each instance variable of their meal. For example, their should be a getMealRecipe, getMealCalories and getMealName getter methods to access information about the meal.

The Chef class should also have a toString that when printed returns the name of the chef, the restaurant they work at, and the meal that they are best known for:

Chef Karel works at Chuck E Cheese and is best known for Toast, which has 100 calories.

There is a Meal and Chef already prepared for you in the ChefTester class. Please add another meal and chef and print the toString and the meal recipe to the console.

In this exercise, we will create two distinct classes, a Meal anda Chef. A Meal consists of three attributes - a name, thenumber of calories in the meal, and a recipe. The Meal class

1 public class Chef 2- { FILES } Chef Tester.java Chef.java Meal.java = 1 public class Meal 2-{ FILES 4 } Chef Tester.java Chef.java Meal.java B public class ChefTester 2-{ 3 4. FILES public static void main(String[] args) { Meal macaroni = new Meal("Mac N Cheese", 500, "Boil macaroni for 8 mins, then add cheese with a little milk."); Chef alex = new Chef("Alex", "Juniors Cheesecake", macaroni); 6 7 ChefTester.java System.out.println(alex); System.out.println(alex.getMealRecipe()); Chef.java Meal.java //Create your own Meal and Chef here: 9 10 11 12 13 14 } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!