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;
           }
       }
    }
  • 相关阅读:
    activeMQ
    读写xml
    PLSQL
    oracle语法
    cxf远程调用服务
    FastDFS在linux下的安装和整合nginx实现上传图片和url访问
    dubbo和zookeeper的应用
    solr和Lucene的配置方式和应用
    win10 下安装 MongoDB 数据库支持模块(python)
    nodeJs 对 Mysql 数据库的 curd
  • 原文地址:https://www.cnblogs.com/jianhongtang2016/p/7143398.html
Copyright © 2011-2022 走看看