封装、策略

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace 算
{
public interface Isuan
{
int calculate(int a, int b);
}
public class add : Isuan
{
public int calculate(int a,int b)
{
return a + b;
}
}
public class sub : Isuan
{
public int calculate(int a, int b)
{
return a - b;
}
}
public class mal : Isuan
{
public int calculate(int a, int b)
{
return a * b;
}
}
public class div : Isuan
{
public int calculate(int a, int b)
{
return a / b;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO; namespace 算
{
class fuhao
{
private Isuan fh;
public fuhao(string a)
{
switch(a)
{
case"+":
fh = new add();
break;
case "-":
fh = new sub();
break;
case "*":
fh = new mal();
break;
case "/":
fh = new div();
break;
}
}
public int jisuan(int a, int b)
{
return fh.calculate(a, b);
} }
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO; namespace 算
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private int An;
private void button2_Click(object sender, EventArgs e)
{
this.Close();
} private void button1_Click(object sender, EventArgs e)
{
fuhao clacuter = new fuhao(comboBox1.Text);
            An = clacuter.jisuan(int.Parse(textBox1.Text), int.Parse(textBox2.Text));
if (textBox3.Text == An.ToString())
{
MessageBox.Show("回答正确!");
}
else
{
MessageBox.Show("回答错误!");
}
textBox1.Clear();
textBox2.Clear();
comboBox1.Text = "";
textBox3.Clear();
} private void textBox3_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
fuhao clacuter = new fuhao(comboBox1.Text);
 An = clacuter.jisuan(int.Parse(textBox1.Text), int.Parse(textBox2.Text)); if (textBox3.Text == An.ToString())
{
MessageBox.Show("回答正确!");
}
else
{
MessageBox.Show("回答错误!");
}
textBox1.Clear();
textBox2.Clear();
comboBox1.Text = "";
textBox3.Clear();
}
}
}
}


asp换脸

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; /// <summary>
///fuhao 的摘要说明
/// </summary>
public class fuhao
{
private Isuan s;
public fuhao(string a)
{
switch (a)
{
case"+":
s = new add();
break;
case "-":
s = new sub();
break;
case "*":
s = new cml();
break;
case "/":
s = new div();
break;
}
}
public int suan(int a, int b)
{
return s.cla(a,b);
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; /// <summary>
///suan 的摘要说明
/// </summary> public interface Isuan
{
int cla(int a, int b);
}
public class add:Isuan
{
public int cla(int a, int b)
{
return a + b;
}
}
public class sub:Isuan
{
public int cla(int a, int b)
{
return a - b;
}
}
public class cml:Isuan
{
public int cla(int a, int b)
{
return a * b;
}
}
public class div:Isuan
{
public int cla(int a, int b)
{
return a / b;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page
{
private int An;
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
fuhao b = new fuhao(TextBox2.Text);
An=b.suan(int.Parse(TextBox1.Text),int.Parse(TextBox3.Text));
if (TextBox4.Text == An.ToString())
{
Response.Write("回答正确!");
}
else
{
Response.Write("回答错误!");
}
}
}

封装,策略,Asp换脸的更多相关文章

  1. 封装,策略模式,Asp换脸

    1.简单封装 1>计算类 using System; using System.Collections.Generic; using System.Linq; using System.Text ...

  2. Angular2-三种样式封装策略的区别

    Angular2有三种样式封装方式,分别是None.Native.Emulated. 可用元数据“encapsulation”配置,配置方式如下: encapsulation: ViewEncapsu ...

  3. Wpf+数据库代码封装+策略模式封装

    运行界面: 数据库保存的题: 数据库封装代码: using System; using System.Collections.Generic; using System.Linq; using Sys ...

  4. 计算器简单封装和ASP.net

    封装: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ...

  5. 自己封装的ASP.NET的MYSQL的数据库操作类

    /** * 作者:牛腩 * 创建时间:2010年3月7日17时35分 * 类说明:对MYSQL数据库的操作类 */ using System; using System.Data; using MyS ...

  6. 使用NetBox实现ASP网页封装为EXE教程

    简单的形容就是把ASP文件打包 成一个EXE文件,并且不需要在调试的机器上安装IIS即可正常调试.如果按照说明书来操作的话,观看比较繁琐,本人为方便大家使用,现制作一个简单的使用教程. 封装过程 1. ...

  7. 在 ASP.NET Core Web API中使用 Polly 构建弹性容错的微服务

    在 ASP.NET Core Web API中使用 Polly 构建弹性容错的微服务 https://procodeguide.com/programming/polly-in-aspnet-core ...

  8. javascript设计模式:策略模式

    前言 策略模式有效利用组合.委托.多态等技术和思想,可以有效避免多重条件选择语句. 策略模式对开放-封闭原则提供了很好的支持,将算法封装在strategy中,使得他们易于切换.理解.扩展. 策略模式中 ...

  9. IOS之Objective-C学习 策略模式

    对于策略模式,我个人理解策略模式就是对各种规则的一种封装的方法,而不仅仅是对算法的封装与调用而已.与工厂模式中简单工厂有点类似,但是比简单工厂更有耦合度,因为策略模式以相同的方法调用所有的规则,减少了 ...

随机推荐

  1. html5复习--canvas

    一.简介 <canvas>是html5新增的标签,可以使用脚本(通常为JavaScript)在其中绘制图像的 HTML 元素.它可以用来制作照片集或者制作简单(也不是那么简单)的动画,甚至 ...

  2. Mac端 Open GL初探

    一.环境配置 1.创建macOS工程 2.添加OpenGL.framework和GLUT.framework两个系统库 3.拖入资源文件 如果libGLTools.a问价先拖入到工程其他位置,后再移到 ...

  3. kali linux修改更新源及更新

    1.修改sources.list源文件: leafpad /etc/apt/sources.list #aliyun 阿里云 deb http://mirrors.aliyun.com/kali ka ...

  4. 大数据入门第五天——离线计算之hadoop(下)hadoop-shell与HDFS的JavaAPI入门

    一.Hadoop Shell命令 既然有官方文档,那当然先找到官方文档的参考:http://hadoop.apache.org/docs/current/hadoop-project-dist/had ...

  5. 最新的Veil3.0的安装和使用

    首先安装 ┌─[root@sch01ar]─[~] └──╼ #cd /sch01ar/Veil/ ┌─[root@sch01ar]─[/sch01ar/Veil] └──╼ #cd setup/ ┌ ...

  6. 20155239吕宇轩 Linux下IPC机制

    20155239吕宇轩 Linux下IPC机制 - 共享内存 原理:把所有需要使用的共享数据都存放在共享内存 区域中,任何想要访问这些共享数据的进程都必须在自己的进程地址空间中新增加一块内存区域,用来 ...

  7. 北京Uber优步司机奖励政策(4月20日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  8. 【LG3295】[SCOI2016]萌萌哒

    [LG3295][SCOI2016]萌萌哒 题面 洛谷 题解 考虑现在我们如果一次只是限定两个位置相等该怎么做, 直接将这些位置用并查集并起来然后答案就是 \[ ans= \begin{cases} ...

  9. 2_C语言中的数据类型 (七)printf与scanf

    1          字符串格式化输出和输入 1.1       字符串在计算机内部的存储方式 字符串是内存中一段连续的char空间,以’\0’结尾 “”是C语言表达字符串的方式 1.2       ...

  10. python爬虫之Scrapy框架(CrawlSpider)

    提问:如果想要通过爬虫程序去爬取”糗百“全站数据新闻数据的话,有几种实现方法? 方法一:基于Scrapy框架中的Spider的递归爬去进行实现的(Request模块回调) 方法二:基于CrawlSpi ...