[Head First设计模式]云南米线馆中的设计模式――模版方法模式(二)

2014-11-24 02:45:29 · 作者: · 浏览: 1
ng water");
17 }
18 public void PourInCup()
19 {
20 Console.WriteLine("Pouring into cup");
21 }
22
23 }
复制代码
4、咖啡和茶都依赖于超类(咖啡因饮料)处理冲泡法。
复制代码
1 public class Coffee : CaffeineBeverage
2 {
3 public override void Brew()
4 {
5 Console.WriteLine("Dripping Coffee through filter");
6 }
7
8 public override void AddCondiments()
9 {
10 Console.WriteLine("Adding Sugar and Milk");
11 }
12 }
复制代码
复制代码
1 public class Tea : CaffeineBeverage
2 {
3 public override void Brew()
4 {
5 Console.WriteLine("Steeping the tea");
6 }
7
8 public override void AddCondiments()
9 {
10 Console.WriteLine("Adding Lemon");
11 }
12 }