接口

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace susuusu
{
interface Interface1
{
int calculate(int a, int b,int c);
}
}

加法类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace susuusu
{
class Add:Interface1
{
public int calculate(int a, int b,int c)
{
return a + b + c;
}
}
}

减法类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace susuusu
{
class Subtract:Interface1
{
public int calculate(int a, int b, int c)
{
return a - b - c;
}
}
}

乘法类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace susuusu
{
class Multiply:Interface1
{
public int calculate(int a, int b, int c)
{
return a * b * c;
}
}
}

除法类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace susuusu
{
class Except:Interface1
{
public int calculate(int a, int b, int c)
{
return a / b / c;
}
}
}

环境角色

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace susuusu
{
class Environment
{
private Interface1 inter;
public Environment(Interface1 face)
{
inter = face;
}
public Interface1 gewrt()
{
return inter;
}
public void setwrt(Interface1 face)
{
inter = face;
}
public int calculate(int a, int b,int c)
{
return inter.calculate(a, b,c);
}
}
}

Main方法

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace susuusu
{
class Program
{
static void Main(string[] args)
{
Add addss = new Add();
Environment environment = new Environment(addss);
Console.WriteLine( environment.calculate(4, 5,7));
Subtract subtrss = new Subtract();
Environment environment1 = new Environment(subtrss);
Console.WriteLine(environment1.calculate(911, 81, 2));
Multiply mulit = new Multiply();
Environment environment2 = new Environment(mulit);
Console.WriteLine(environment2.calculate(12, 45, 12));
Except except1 = new Except();
Environment environment3 = new Environment(except1);
Console.WriteLine(environment3.calculate(81, 9, 9));
Console.ReadLine();
}
}
}

总结

总的感觉来书还是控制台比较好写一些!在不同的环境下写相同的程序,感受一下不同!

Calculation控制台的更多相关文章

  1. C#基础之------控制台进程

    /********************************************************************************* File:C#实现100以内两个数 ...

  2. .NET平台开源项目速览(17)FluentConsole让你的控制台酷起来

    从该系列的第一篇文章 .NET平台开源项目速览(1)SharpConfig配置文件读写组件 开始,不知不觉已经到第17篇了.每一次我们都是介绍一个小巧甚至微不足道的.NET平台的开源软件,或者学习,或 ...

  3. .NET Core的日志[2]:将日志输出到控制台

    对于一个控制台应用,比如采用控制台应用作为宿主的ASP.NET Core应用,我们可以将记录的日志直接输出到控制台上.针对控制台的Logger是一个类型为ConsoleLogger的对象,Consol ...

  4. node.js学习(二)--Node.js控制台(REPL)&&Node.js的基础和语法

    1.1.2 Node.js控制台(REPL) Node.js也有自己的虚拟的运行环境:REPL. 我们可以使用它来执行任何的Node.js或者javascript代码.还可以引入模块和使用文件系统. ...

  5. 在.NET Core控制台程序中使用依赖注入

    之前都是在ASP.NET Core中使用依赖注入(Dependency Injection),昨天遇到一个场景需要在.NET Core控制台程序中使用依赖注入,由于对.NET Core中的依赖注入机制 ...

  6. Chrome 控制台不完全指南

    Chrome的开发者工具已经强大到没朋友的地步了,特别是其功能丰富界面友好的console,使用得当可以有如下功效: 更高「逼格」更快「开发调试」更强「进阶级的Frontender」 Bug无处遁形「 ...

  7. Log4net入门(控制台篇)

    Log4net是Apache公司的log4j™的.NET版本,用于帮助.NET开发人员将日志信息输出到各种不同的输出源(Appender),常见的输出源包括控制台.日志文件和数据库等.本篇主要讨论如何 ...

  8. chrome控制台模拟hover、focus、active等状态,方便调试

    有时候需要调试一个网页,需要某些元素在hover.focus.active等状态. 比如hover,鼠标放到hover上,然后去控制台中找DOM,鼠标移开的时候元素就不是hover状态了. 此时可以使 ...

  9. Delphi_01_控制台版HelloWorld

    对于Windows下的控制台编程,我相信很多人都不陌生.而C语言开始的著名的“Hello world”程序基本是学习编程的第一步.我想对于 RAD开发,大家熟悉的一般都是GUI编程,而对于consol ...

随机推荐

  1. RocEDU.阅读.写作

    RocEDU.阅读.写作 一.选择图书 <黑客大曝光> 二.读书计划 56天内学习完.时间:2016.01.25--2016.03.20 三.承诺 宋宸宁郑重承诺: 1.在56天内(开始时 ...

  2. 企业服务总线(ESB)

    思考: 1.ESB的定义到底是什么?是一款产品还是一种架构模式? 2.ESB有何实际用处? 定义ESB 对于企业服务总线(Enterprise Service Bus),目前还没有公认的定义,根据供应 ...

  3. DPM总结

    DPM:Deformable Parts Model(来自http://www.cs.berkeley.edu/~rbg/latent/index.html) 目标检测算法 先计算梯度方向直方图,在用 ...

  4. 安装MVC3后没有dbcontext生成器的解决方案

    安装MVC3后,采用DBFIRS的方式,从数据库生成模型,这样生成的类是基于ObjectContext的,无法使用DbContext的一些方法,比如Set.Find.Entry等.需要用ADO.NET ...

  5. Java学习-035-JavaWeb_004 -- JSP include 指令

    inclue 指令是将不同的文件插入到 JSP 网页中,这些文件可以是文本文件.HTML文件.JSP 文件,指令语法如下: <%@include file="相对路径"%&g ...

  6. emmc boot1 boot2 partition

    使用mfg tool烧写android5.1的镜像之后,再使用旧版的mfg tool烧写linux或者android镜像,都不能正常启动,而且运行的uboot还是android5.1版本的uboot. ...

  7. imx6 u-boot.bin 和 u-boot.imx

    有些MFG TOOL烧录工具使用了u-boot.imx,而不是原来的u-boot.bin文件进行烧录. 这两个镜像的区别是,u-boot.bin文件编译后,会在u-boot.bin的开头添加一个大小为 ...

  8. 每日目标——HTML 头部标签学习 2015-8-27

    <head> <title>bp</title> <meta http-equiv="Content-Type" content=&quo ...

  9. C语言:其他进制数转换为十进制(方法一)

    #include<stdio.h> #include<math.h> #include<string.h> //其他任意进制转换为十进制 int main() { ...

  10. linux安装MySQL5.7.13(二进制|源码)

    二进制和源码版本安装MySQL5.7.13,并简单介绍不同之处. 一.通用二进制部分 1.下载MySQL通用二进制软件包.[root@node1 ~]# wget http://120.52.72.2 ...