接口

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. 记录下 QT Linux 静态编译遇到的坑

    Qt下静态编译Qt,根据我的经验,如果按照Windows下那种直接拿官方sdk安装之后的文件来编译是行不通的,需要直接下载Qt的source包,目前诺基亚的源码叫做qt-everywhere-open ...

  2. 【Java 基础篇】【第六课】接口interface

    Java提供的这个interface的语法,目的就是将接口从类中剥离出来,构成独立的主体. 首先加入我们定义了这个杯子接口: interface Cup { void addWater(int w); ...

  3. php--在apache上配制rewrite重写

    配置步骤: 第一步:找到apache的配置文件httpd.conf(文件在conf目录下) 第二步:你首先必须得让服务器支持mod_rewrite,如果你使用的是虚拟主机,请事先询问你的主机提供商. ...

  4. pod setup》error: RPC failed; result=18, HTTP code = 200

    Try reducing the postBuffer size in the remote repository config. Follow the steps below Go to remot ...

  5. 如何方便的控制css3动画开始时间点与持续时间

    一般我们在控制css3 animate动画时可以通过简写以减少代码量,只要在需要动画的元素上追加一下类名就可以了,如下例子 /*淡入并向上移动一点位置出现*/ .fadeInUp{ -webkit-a ...

  6. MVC在VIEW中动态控制htmlAttributes和routevalues的方法

    在项目中有一个Html.DropDownListFor放在一个分部视图中,然后调用这个分部视图时需要动态控制这个DropDownList的显示方式,比如宽度.是否禁用.是否列表等,这些值的设置都在Ht ...

  7. CENTOS安装vnc

    先直接进入命令模式,如果是服务器则可以使用putty连接进入命令行模式. 现在知道的centos下的vnc是:tigervnc,由于是服务端所以我们只安装tigervnc-server即可: yum ...

  8. LightOj1418 - Trees on My Island(Pick定理)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1418 题意:给你多边形中的顶点,n个点按顺时针或逆时针方向给出,然后求出多边形内部有多 ...

  9. nginx源码分析—内存池结构ngx_pool_t及内存管理

    Content 0. 序 1. 内存池结构 1.1 ngx_pool_t结构 1.2 其他相关结构 1.3 ngx_pool_t的逻辑结构 2. 内存池操作 2.1 创建内存池 2.2 销毁内存池 2 ...

  10. Oracle数据库之SQL基础(一)

    主要内容:用户与表空间:表与约束:查询语句. 一.概述 Oracle安装:访问官网,下载 二.用户与表空间 在安装Oracle时在开始菜单里可以用sql puls登录oracle. ★1.系统用户 s ...