封装,策略,Asp换脸
封装、策略
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换脸的更多相关文章
- 封装,策略模式,Asp换脸
1.简单封装 1>计算类 using System; using System.Collections.Generic; using System.Linq; using System.Text ...
- Angular2-三种样式封装策略的区别
Angular2有三种样式封装方式,分别是None.Native.Emulated. 可用元数据“encapsulation”配置,配置方式如下: encapsulation: ViewEncapsu ...
- Wpf+数据库代码封装+策略模式封装
运行界面: 数据库保存的题: 数据库封装代码: using System; using System.Collections.Generic; using System.Linq; using Sys ...
- 计算器简单封装和ASP.net
封装: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ...
- 自己封装的ASP.NET的MYSQL的数据库操作类
/** * 作者:牛腩 * 创建时间:2010年3月7日17时35分 * 类说明:对MYSQL数据库的操作类 */ using System; using System.Data; using MyS ...
- 使用NetBox实现ASP网页封装为EXE教程
简单的形容就是把ASP文件打包 成一个EXE文件,并且不需要在调试的机器上安装IIS即可正常调试.如果按照说明书来操作的话,观看比较繁琐,本人为方便大家使用,现制作一个简单的使用教程. 封装过程 1. ...
- 在 ASP.NET Core Web API中使用 Polly 构建弹性容错的微服务
在 ASP.NET Core Web API中使用 Polly 构建弹性容错的微服务 https://procodeguide.com/programming/polly-in-aspnet-core ...
- javascript设计模式:策略模式
前言 策略模式有效利用组合.委托.多态等技术和思想,可以有效避免多重条件选择语句. 策略模式对开放-封闭原则提供了很好的支持,将算法封装在strategy中,使得他们易于切换.理解.扩展. 策略模式中 ...
- IOS之Objective-C学习 策略模式
对于策略模式,我个人理解策略模式就是对各种规则的一种封装的方法,而不仅仅是对算法的封装与调用而已.与工厂模式中简单工厂有点类似,但是比简单工厂更有耦合度,因为策略模式以相同的方法调用所有的规则,减少了 ...
随机推荐
- Oracle cursors 游标 for循环遍历
oracle提供了for循环语句,让我们可以遍历select搜索的结果.用法也很简单,代码如下: DECLARE ; BEGIN FOR C IN C1 LOOP -- 对select出的每一行进行操 ...
- MySQL学习【第六篇sql语句下】
一.select高级用法 1.传统连接(只能内连接,取交集,效率最慢) 1.根据两张表查询张三成绩 select t1.sname,t2.mark from t1,t2 where t1.sid=t2 ...
- hive--数据仓库
1.1.1 hive是什么? Hive是基于 Hadoop 的一个数据仓库工具: 1. hive本身不提供数据存储功能,使用HDFS做数据存储: 2. hive也不分布 ...
- ARM Linux驱动篇 学习温度传感器ds18b20的驱动编写过程
ARM Linux驱动篇 学习温度传感器ds18b20的驱动编写过程 原文地址:http://www.cnblogs.com/NickQ/p/9026545.html 一.开发板与ds18b20的入门 ...
- 2017-2018-1 20155313 《信息安全系统设计基础》 Myod
2017-2018-1 20155313 <信息安全系统设计基础> Myod Myod要求 1.复习c文件处理内容 2.编写myod.c 用myod XXX实现Linux下od -tx - ...
- iOS开发-通过正则表达式进行各种判断银行卡,车牌号,邮箱地址,QQ,身份证,全字母,仅输入字母或数字同时包含大小写字母和数字,仅能输入中文等
/* * 验证银行卡号是否正确 * 车牌号验证 * 检验邮箱地址是否正确 * 手机号中间四位密文显示 * 判断QQ号是否正确(5-11位) * 判断身份证号是否正确(如末位为字母请用“x” ...
- 洛咕 P2465 [SDOI2008]山贼集团
裸的状压dp. 设f[i][j]表示在i字数内放j集合的分部,直接sb转移. // luogu-judger-enable-o2 #include<bits/stdc++.h> #defi ...
- 【PaPaPa】集成B/S主流技术的MVC5项目 - 实干派:说做就做,我们已经起航,你还在观望吗
我们是谁 我们是C#爱好者,互相分享技术,一起学习一起成长一起做一个项目. 我们是开源爱好者,从我们手上出来的代码都会托管在源代码管理平台(oschina),到目前为止不收费,将来也不会出现任何收费情 ...
- async/await工作机制探究--NodeJS
ES6中的async/await让Promise变得更加简便,通常await处理的链式Promise会包裹在函数中,返回结果仍然是一个Promise对象. 但是当await直接处理链式Promise时 ...
- appium移动自动化测试---api键盘操作
模拟键盘输入也是非常重要的操作.这一小节来介绍那些关于键盘的操作. 1.sendKeys()方法 方法: sendKeys() 用法: driver.findElements(By.name(&quo ...