Template Method

Report a typo

Now, we'll add a new concrete class Sandwich.

Sandwich is different from Steak, that's why you need to implement it.

The first line of the standard input is the concrete meal.

You must output the meal procedure.

Please do not change the provided code of the classes.

Sample Input 1:

Sandwich

Sample Output 1:

Ingredients: bacon, white bread, egg, cheese, mayonnaise, tomato
Paste ingredients between bread slices. Toast sandwich
That's good
Lick fingers and go to sleep
Write a program in Java 17
import java.util.Scanner;

abstract class Meal {

/**
* It provides template method of meal routine.
*/
public void doMeal() {
// write your code here ...
}

public abstract void prepareIngredients();

public abstract void cook();

public void eat() {
System.out.println("That's good");
}

public abstract void cleanUp();
}

class Steak extends Meal {

@Override
public void prepareIngredients() {
System.out.println("Ingredients: beef steak, lemon, olive oil, salt, sugar");
}

@Override
public void cook() {
System.out.println("Fry the steak in the pan");
}

@Override
public void cleanUp() {
___

Create a free account to access the full topic