zoukankan      html  css  js  c++  java
  • 简单工厂模式

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace 简单工厂模式
    {
       public class OperationFactory
       {
           public static Operation craateOperation(string operate)
           {
               Operation oper = null;
               switch (operate)
               {
                   case "+":
                       oper = new OpertionAdd();
                       break;
                   case "-":
                       oper = new OpertionSub();
                       break;
                   case "*":
                       oper = new OpertionMul();
                       break;
                   case "/":
                       oper = new OpertionDiv();
                       break;   
               }
               return oper;
           }
       }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace 简单工厂模式
    {
       public class Operation
       {
           private double _numberA = 0;
           private double _numberB = 0;
    public double NumberA
           {
               get { return _numberA; }
               set { _numberA = value; }
           }
           public double NumberB
           {
               get { return _numberB; }
               set { _numberB = value; }
           }
    
           public virtual double GetResult()
           {
               double result = 0;
               return result;
           }
       }
    }
  • 相关阅读:
    立项管理--复习需加强知识点
    Python函数中的->none是什么意思和作用
    信息系统项目管理基础--复习需加强知识点
    python笔记
    案例分析--课堂笔记
    对下载的软件包做校验
    pc端和公众号同时开发的方案选择
    应用服务器拖垮数据库问题排查
    常用的idea插件
    如何进行后端开发 (大体逻辑)
  • 原文地址:https://www.cnblogs.com/jianhongtang2016/p/7143398.html
Copyright © 2011-2022 走看看