.net模式门面模式设计

 时间:2026-02-19 10:10:35

1、新建一个控制台应用程序,命名为门面模式,如下图所示:

.net模式门面模式设计

2、新建一个相机类Camera类,添加相应方法,如下图所示:

public class Camera

    {

        public void TurnOn()

        {

            Console.WriteLine("turning on the camera.");

        }

        public void TurnOff()

        {

            Console.WriteLine("turning off the camera.");

        }

        public void Rotate(int degrees)

        {

            Console.WriteLine("Rotating the camera by {0} degrees.", degrees);

        }

    }

.net模式门面模式设计

3、新建Light类,增加一些方法实现:

 public class Light

    {

        public void TurnOff()

        {

            Console.WriteLine("Turning on the light.");

        }

        public void TurnOn()

        {

            Console.WriteLine("Turning off the light.");

        }

        public void ChangeBulb()

        {

            Console.WriteLine("changing the light-bulb.");

        }

    }

.net模式门面模式设计

4、根据上面的方法,增加Sensor与Alarm类,如下图

.net模式门面模式设计

.net模式门面模式设计

5、添加实现类,执行主方法,如下图:

.net模式门面模式设计

6、运行程序,得到执行结果。

.net模式门面模式设计

  • 如何估价门面房
  • 奶茶店门面选址技巧
  • .net 调用摄像头拍照
  • 怎样快速转掉门面
  • 仪表是你的门面
  • 热门搜索
    鹣鲽怎么读 湘菜的特点 东山岛旅游攻略 可以试看很多的体验区10分钟 爱奇艺会员可以几个人用 怎么卸载360浏览器 宁夏旅游景点 传奇霸业攻略 灌汤包的皮怎么做 笔记本的摄像头怎么打开