设计模式:外观模式与享元模式解析
外观模式(Facade Pattern)
实现代码
以下是外观模式的实现代码,包含了机器人不同部件的类以及外观类和主程序类。
// RobotBody.cs
using System;
namespace FacadePattern.RobotParts
{
public class RobotBody
{
public void CreateHands()
{
Console.WriteLine("Hands manufactured");
}
public void CreateRemainingParts()
{
Console.WriteLine("Remaining parts (other than hands) are created");
}
public void DestroyHands()
{
Console.WriteLine("The robot's hands are destroyed");
}
public void DestroyRemainingParts()
{
Console.WriteLine("The robot's remaining parts are destroyed");
}
}
}
//RobotColor.cs
usi
超级会员免费看
订阅专栏 解锁全文

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



