封装,策略,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学习 策略模式
对于策略模式,我个人理解策略模式就是对各种规则的一种封装的方法,而不仅仅是对算法的封装与调用而已.与工厂模式中简单工厂有点类似,但是比简单工厂更有耦合度,因为策略模式以相同的方法调用所有的规则,减少了 ...
随机推荐
- jQuery 插件运用
1. fullpage 插件(全屏) 官网:http://www.jq22.com/ jqueryui 官网:http://jqueryui.com/draggable/ 1.1 使用方法 引入文件 ...
- Phpstorm如何连接服务器
当服务器是Linux的时候不懂指令觉得很懊恼,这个时候直接就可以使用PHPstorm连接服务器操作了: 1丶准备工作 首先你先要准备服务器丶phpstorm这两个吧! 2丶开始配置phpstorm 按 ...
- PHP分行打印数组-php输出数组方法大全
我们都知道php有两种方式可以打印数组 $arr = array( "a"=>"orange", "b"=>"bana ...
- PHP操作xml学习笔记之增删改查(1)—增加
xml文件 <?xml version="1.0" encoding="utf-8"?><班级> <学生> ...
- Linux--find命令和 xargs命令组合
find 查找文件的命令,并可以做出相应的处理 命令格式: find filename [选项][-print -exec -ok ...] 选项参数: 1.-name :按照文件名称查找,可以提前c ...
- Ghostscript远程代码执行漏洞利用方法
昨天爆出来的Ghostscript远程代码执行漏洞,复现过程如下 1.确认系统是否安装了gs 执行命令 gs -q -sDEVICE=ppmraw -dSAFER -sOutputFile=/dev/ ...
- 基于VHDL的8255可编程并行接口电路设计
一.实验题目名称: 8255可编程并行接口电路设计 二.实验目的.任务和要求: 实验目的:学习掌握基本的数字系统设计方法,建立自顶向下的设计思维,能够使用VHDL语言编写简单的应用IP核,掌握基本的F ...
- jQuery学习- 获取与设置属性的函数
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 16-[JavaScript]-ECMAScript 2
1.流程控制:if switch <!DOCTYPE html> <html> <head> <meta charset="UTF-8"& ...
- 网络设备重的loopback接口
回环接口在我们做试验的过程有典型的应用,几乎可以离不开它,一个虚拟的接口,给我带来了很大的方便,有了回环接口,你可以不用为你的PC,来添加第二块物理网卡,就可以完成VM,服务器搭建,群集,VPN等试验 ...