Abstract Class (Recipe):?
- The Recipe class defines the template method Cook, which contains the algorithm's
skeleton. It delegates the implementation of specific steps (GatherIngredients,
Prepare, and CookMethod) to subclasses by making them abstract. The Serve
method is concrete and always executes the same way for all recipes.
public abstract class Recipe
public void Cook()
Follow:
GatherIngredients();
Prepare();
CookMethod();
Serve();
protected abstract void GatherIngredients();
protected abstract void Prepare();
protected abstract void CookMethod();
private void Serve() => Console.WriteLine("Serving the dish.");