接口

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. session和cookie区别

    <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//E ...

  2. LightOj 1024 - Eid (求n个数的最小公约数+高精度)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1024 题意:给你n(2<=n<=1000)个数, 然后求n个数的最小公倍数 ...

  3. win10 + gtx1060 + cuda8.0 + caffe + vs2013

    1. 安装cuda8.0 1)先去官网下载cuda8.0  https://developer.nvidia.com/cuda-toolkit 2)下载完之后进行安装,安装时间有点长,请耐心等待,默认 ...

  4. LeetCode Basic Calculator II

    原题链接在这里:https://leetcode.com/problems/basic-calculator-ii/ Implement a basic calculator to evaluate ...

  5. cat 命令(转)

    cat命令的用途是连接文件或标准输入并打印.这个命令常用来显示文件内容,或者将几个文件连接起来显示,或者从标准输入读取内容并显示,它常与重定向符号配合使用. 1.命令格式: cat [选项] [文件] ...

  6. 【干货】分享总结:MySQL数据一致性 罗小波 星辉天拓

    [干货]分享总结:MySQL数据一致性  罗小波  星辉天拓 http://mp.weixin.qq.com/s?__biz=MjM5NzAzMTY4NQ==&mid=2653928966&a ...

  7. Android Error:warning: Ignoring InnerClasses attribute for an anonymous inner class

    今天项目发布时遇到了这个问题,在低版本设备上面死活发布不上去,还有打包也打不成功,折腾了好长一段时间,网上大部分给出的 解决方案都是说 在工程的混淆配置文件 proguard-rules.pro 中加 ...

  8. SQL Server中的SQL语句优化与效率问题

    很多人不知道SQL语句在SQL SERVER中是如何执行的,他们担心自己所写的SQL语句会被SQL SERVER误解.比如: select * from table1 where name='zhan ...

  9. 第八篇 Integration Services:高级工作流管理

    本篇文章是Integration Services系列的第八篇,详细内容请参考原文. 简介在前面两篇文章,我们创建了一个新的SSIS包,学习了SSIS中的脚本任务和优先约束,并检查包的MaxConcu ...

  10. sqlserver 2000事务复制问题

    2000现在用的估计不多了,把之前收集的一些复制问题整理发布出来.可能都是些很白很二的问题,但人总是由最初的无知不断成长,不对之处欢迎指正. sqlserver 2000事务复制问题服务器A(发布) ...