Add template method example

This commit is contained in:
Petrutiu Mihai
2016-07-06 09:38:55 +03:00
parent a8aa2a5a18
commit 161e6b7c03
12 changed files with 217 additions and 2 deletions

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace TemplatePattern.WorkersExample
{
/// <summary>
/// Framework class
/// </summary>
public abstract class Worker
{
public void StartWorking()
{
WakeUpAndDrinkCoffee();
TakeAShower();
GetDressed();
GoToWork();
Work();
}
protected virtual void WakeUpAndDrinkCoffee()
{
Console.WriteLine("Wake up and drink coffee normally");
}
protected virtual void TakeAShower()
{
Console.WriteLine("Take a shower");
}
protected virtual void GetDressed()
{
Console.WriteLine("Get dressed");
}
protected virtual void GoToWork()
{
Console.WriteLine("Go to work");
}
protected abstract void Work();
}
}