using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TemplateMethodPattern
{
/// <summary>
/// 模拟起床步骤,但是男人起床和女人起床是不一样的
/// </summary>
public abstract class AbstractRise
{
public void Rise()
{
XiLian();
ShuaYa();
ChuanYi();
ChuMen();
}
/// <summary>
/// 洗脸
/// </summary>
public abstract void XiLian() ;
/// <summary>
/// 刷牙
/// </summary>
public abstract void ShuaYa() ;
/// <summary>
/// 穿衣
/// </summary>
public abstract void ChuanYi() ;
/// <summary>
/// 出门
/// </summary>
public abstract void ChuMen();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TemplateMethodPattern
{
class ManRise:AbstractRise
{
public override void XiLian()
{
Console.WriteLine("凉水快速希望!");
}
public override void ShuaYa()
{
Console.WriteLine("高频刷牙!");
}
public override void ChuanYi()
{
Console.WriteLine("拽出一件衣服穿上!");
}
public override void ChuMen()
{
Console.WriteLine("检查一下手机、钥匙、钱包、公交卡走人!");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TemplateMethodPattern
{
class WomanRise:AbstractRise
{
public override void XiLian()
{
Console.WriteLine("温水+洗面奶,要清洗干净细致!");
}
public override void ShuaYa()
{
Console.WriteLine("刷三分钟!");
}
public override void ChuanYi()
{
Console.WriteLine("今天穿什么衣服呢?这件衣服吧!但是裤子没法搭配啊,这件吧,不行太老土了。。。。各种纠结!");
}
public override void ChuMen()
{
Console.WriteLine("化个妆眼影、口红、描眉、睫毛。。。。!");
}
}
}