接口

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. jquery全选+下拉+单选+事件+挂事件

    1.全选 <body> <input type="checkbox" id="qx" /> 全选 <input type=&quo ...

  2. 低功耗蓝牙BLE [学习笔记]

    手机设备会区分 "connecting" and "pairing" ,前者可以自动连接,后者则需要请求.BLE不再有pairing的麻烦,能直接连上目标设备, ...

  3. JS 去字符串空格 总结

    str为要去除空格的字符串: 去除所有空格: str = str.replace(/\s+/g,""); 去除两头空格: str = str.replace(/^\s+|\s+$/ ...

  4. HashSet HashTable HashMap的区别

    (1)HashSet是set的一个实现类,hashMap是Map的一个实现类,同时hashMap是hashTable的替代品(为什么后面会讲到). (2)HashSet以对象作为元素,而HashMap ...

  5. python 十进制 十六进制

    把十六进制的字串转为十进制数字:>>> print int('ff', 16)   255 把十进制数字转换为以十六进制表示之字串,可调用内置的hex()函数:>>> ...

  6. 关于android获得设备宽高

    传统的办法: DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(d ...

  7. 批量处理_cmd_matlab

    cd \ cd D:\Projects_Face_Detection\Datasets\afw d: dir /b/s/p/w *jpg > Path_Images.txt 1.ground_t ...

  8. LeetCode Course Schedule II

    原题链接在这里:https://leetcode.com/problems/course-schedule-ii/ 题目: There are a total of n courses you hav ...

  9. 智能硬件+App移动新生态【10.24北京站】

    活动概况 时间:2015年10月24日13:30-16:30 地点:Wepac空间(海淀区北四环西路68号左岸工社6层) 主办:APICloud.机智云.智石科技.华为云 网址:www.apiclou ...

  10. 30天,O2O速成攻略【8.30南京站】

    活动概况 时间:2015年8月30日13:30-16:30 地点:啡咖啡·孵化器(南京市玄武大道699-22号江苏软件园22栋) 主办:APICloud.Udesk.人为峰 网址:www.apiclo ...