外观模式
using System;
namespace MyApp
{
class Program
{
static void Main()
{
Console.WriteLine(new AF().AFWay().ToString());
Console.ReadKey();
}
}
class AF
{
AC ac = new AC();
AD ad = new AD();
CF cf = new CF();
DF df = new DF();
public int AFWay()
{
int _ac=ac.ACWay();
int _ad=ad.ADWay();
int _cf=cf.CFWay();
int _df=df.DFWay();
return _ac + _cf > _ad + _df ? _ad + _df : _ac + _cf;
}
}
class AC
{
public int ACWay()
{
return 1;
}
}
class AD
{
public int ADWay()
{
return 2;
}
}
class CF
{
public int CFWay()
{
return 2;
}
}
class DF
{
public int DFWay()
{
return 1;
}
}
}
本文介绍了一种常用的软件设计模式——外观模式。它通过提供一个统一的高层接口来简化子系统的使用,使得开发者能够更加方便地调用子系统中的多个组件。
1125

被折叠的 条评论
为什么被折叠?



