Csharp/C Sharp/Design Patterns/Template Pattern
Версия от 15:31, 26 мая 2010; (обсуждение)
Template Method Pattern
using System;
public abstract class Calculate {
public abstract void PositionLabel();
public void SetupCalculate() {
this.PositionLabel();
}
public Calculate() {}
}
public class CalculateDeluxe : Calculate {
public override void PositionLabel() {
Console.WriteLine("Deluxe clock");
}
public CalculateDeluxe() { ;}
}
public class CalculateStandard : Calculate {
public override void PositionLabel() {}
public CalculateStandard() {}
}
class Client {
static void Main(string[] args) {
Calculate delCalculate = new CalculateDeluxe();
delCalculate.SetupCalculate();
Calculate stdCalculate = new CalculateStandard();
stdCalculate.SetupCalculate();
}
}