Calculation控制台
接口
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控制台的更多相关文章
- C#基础之------控制台进程
/********************************************************************************* File:C#实现100以内两个数 ...
- .NET平台开源项目速览(17)FluentConsole让你的控制台酷起来
从该系列的第一篇文章 .NET平台开源项目速览(1)SharpConfig配置文件读写组件 开始,不知不觉已经到第17篇了.每一次我们都是介绍一个小巧甚至微不足道的.NET平台的开源软件,或者学习,或 ...
- .NET Core的日志[2]:将日志输出到控制台
对于一个控制台应用,比如采用控制台应用作为宿主的ASP.NET Core应用,我们可以将记录的日志直接输出到控制台上.针对控制台的Logger是一个类型为ConsoleLogger的对象,Consol ...
- node.js学习(二)--Node.js控制台(REPL)&&Node.js的基础和语法
1.1.2 Node.js控制台(REPL) Node.js也有自己的虚拟的运行环境:REPL. 我们可以使用它来执行任何的Node.js或者javascript代码.还可以引入模块和使用文件系统. ...
- 在.NET Core控制台程序中使用依赖注入
之前都是在ASP.NET Core中使用依赖注入(Dependency Injection),昨天遇到一个场景需要在.NET Core控制台程序中使用依赖注入,由于对.NET Core中的依赖注入机制 ...
- Chrome 控制台不完全指南
Chrome的开发者工具已经强大到没朋友的地步了,特别是其功能丰富界面友好的console,使用得当可以有如下功效: 更高「逼格」更快「开发调试」更强「进阶级的Frontender」 Bug无处遁形「 ...
- Log4net入门(控制台篇)
Log4net是Apache公司的log4j™的.NET版本,用于帮助.NET开发人员将日志信息输出到各种不同的输出源(Appender),常见的输出源包括控制台.日志文件和数据库等.本篇主要讨论如何 ...
- chrome控制台模拟hover、focus、active等状态,方便调试
有时候需要调试一个网页,需要某些元素在hover.focus.active等状态. 比如hover,鼠标放到hover上,然后去控制台中找DOM,鼠标移开的时候元素就不是hover状态了. 此时可以使 ...
- Delphi_01_控制台版HelloWorld
对于Windows下的控制台编程,我相信很多人都不陌生.而C语言开始的著名的“Hello world”程序基本是学习编程的第一步.我想对于 RAD开发,大家熟悉的一般都是GUI编程,而对于consol ...
随机推荐
- 报javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception异常 的解决方案
后台错误信息如下: javax.servlet.ServletException: Servlet.init() for servlet springmvc threw exception org.a ...
- [Stanford 2011] Views 知识点
一.view分层 (1)View的结构是分层的,一个view只能有一个父view,但可以有多个子view.子view的顺序是相关的,在数组中的位置越高或者说数字越大,就显示在后面,位置低的显示在前面. ...
- VMware网络配置 - 三种网络模式简介
安装好虚拟机以后,在网络连接里面可以看到多了两块网卡: 其 中VMnet1是虚拟机Host-only模式的网络接口,VMnet8是NAT模式的网络接口,这些后面会详细介绍 选择虚拟机网络模 式方法如下 ...
- JavaScript学习基础部分
JavaScript学习基础 一.简介 1.JavaScript 是因特网上最流行的脚本语言,并且可在所有主要的浏览器中运行,比方说 Internet Explorer. Mozilla.Firefo ...
- JS-001-单选复选按钮操作
此文主要针对 web 页面中常见元素(例如:单选按钮.复选按钮)的 JavaScript 操作,进行简单的源码示例演示,敬请小主们参阅.若有不足之处,敬请大神指正,不胜感激! 话不多言了,直接上码: ...
- LeetCode Count Complete Tree Nodes
原题链接在这里:https://leetcode.com/problems/count-complete-tree-nodes/ Given a complete binary tree, count ...
- Unofficial Windows Binaries for Python Extension Packages
http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
- iOS小技巧2
这段代码是实现了类似QQ空间"我的空间"里面的圆形头像 //圆形的头像 UIImageView * headImage = [[UIImageView alloc]initWith ...
- Centos 6.5系统下搭建Git服务器--失败历程
参考博客 http://www.51hei.com/bbs/dpj-28077-1.html http://www.linuxidc.com/Linux/2014-06/103885p2.htm ht ...
- boost 1.57.0安装
一. PC编译安装boost boost是C++的准标准库,其有两种安装方法. 1. ubuntu下,通过sudo apt-get install libboost-all-dev. 2. 通过源码包 ...