zoukankan      html  css  js  c++  java
  • 模板模式c#(非常简单,但又非常简洁好玩)

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace 模板模式
    {
        public abstract class CarProces
        {
            public abstract void handler1();
            public abstract void handler2();

            public void handler()
            {
                handler1();
                handler2();
            }
        }

        public class BusProcess : CarProces
        {
            public override void handler1()
            {
                Console.WriteLine("car process1");
            }

            public override void handler2()
            {
                Console.WriteLine("car process2");
            }
        }
        public class JeepProcess : CarProces
        {
            public override void handler1()
            {
                Console.WriteLine("jeep process1");
            }

            public override void handler2()
            {
                Console.WriteLine("jeep process2");
            }
        }
        class Program
        {
            static void Main(string[] args)
            {
                CarProces c1=new BusProcess();

                CarProces c2=new JeepProcess();
               c1.handler();
                Console.WriteLine("--------------------");
                c2.handler();
                Console.ReadKey();
            }
        }
    }

  • 相关阅读:
    php IE中文乱码
    Ehab and a 2-operation task (思维题)
    9-7链表数据求和操作
    "巴卡斯杯" 中国大学生程序设计竞赛
    Codeup 问题 B: 算法7-16:弗洛伊德最短路径算法
    一只小蜜蜂...
    结构体作为函数参数(值传递,引用传递,指针传递)
    Codeforces Round # 515 (div.3) A. Vova and Train
    查找最大元素
    JSP复习(part 4)
  • 原文地址:https://www.cnblogs.com/kexb/p/4525244.html
Copyright © 2011-2022 走看看