封装,策略,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学习 策略模式
对于策略模式,我个人理解策略模式就是对各种规则的一种封装的方法,而不仅仅是对算法的封装与调用而已.与工厂模式中简单工厂有点类似,但是比简单工厂更有耦合度,因为策略模式以相同的方法调用所有的规则,减少了 ...
随机推荐
- 微服务系列实践 .NET CORE
从事这个行业转眼已经6年了,从当初刚毕业的在北京朝八晚十,从二环到五环,仍每天精力充沛的小愤青:再到深圳一点一滴的辛勤在软件行业的耕种,从当初单体应用架构到现在微服务架构的经历,回想起来自己的收获倒是 ...
- vue指令:v-model绑定表单控件;v-model与v-bind结合使用
一.v-model绑定表单控件 v-model 双向数据绑定:一般用于表单元素,会忽略表单元素的value.checked.selected的初始值,且将Vue实例的数据作为数据来源. 1. 单行文本 ...
- react中手动重置redux
前段时间使用redux在react-native中,安卓后退两次关闭后redux未清空的问题,一直觉得处理的不够优雅,没有根本解决问题. 后来发现再退出登录后,也有部分数据因为redux的逻辑处理数据 ...
- linux ssh 连接设置
! 本文编辑中 centos ssh 无法连接
- 4- 算法练习leetcode.com
0.五大经典算法 动态规划算法----爬楼梯 分治算法-- 贪心算法---零钱问题 回溯算法---迷宫问题 --深度优先 分支限界法 ----广度优先 1.找出下标范围 1.二分法 li = [1,2 ...
- BZOJ4543 Hotel加强版
题面 $\text{BZOJ}$间接权限题 洛谷的弱化版 题解 三点距离两两相等要满足以下条件: 有一个相同的$\text{LCA}$ 所以如果存在一个点,使得另外两个点在它子树中,距离为$d$,且$ ...
- 4516: [Sdoi2016]生成魔咒
4516: [Sdoi2016]生成魔咒 链接 题意: 求本质不同的子串. 分析: 后缀数组或者SAM都可以. 考虑SAM中每个点的可以表示的子串是一个区间min(S)~max(S),把每个点的这个区 ...
- COGS1871 [国家集训队2011]排队(魏铭)
bzoj:http://www.lydsy.com/JudgeOnline/problem.php?id=2141 cogs:http://cogs.pro:8080/cogs/problem/pro ...
- Spring学习(十八)----- Spring AOP+AspectJ注解实例
我们将向你展示如何将AspectJ注解集成到Spring AOP框架.在这个Spring AOP+ AspectJ 示例中,让您轻松实现拦截方法. 常见AspectJ的注解: @Before – 方法 ...
- linux下ftp连接:530 Permission denied
问题如下:[root@localhost apps]# ftp 10.xxx.xxx.xxxConnected to 10.xxx.xxx.xxx220 (vsFTPd 2.0.5)530 Pleas ...