• 封装,策略,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("回答错误!");
            }
        }
    }

  • 相关阅读:
    phontomjs debug with webkit inspector
    《Node Web开发》((美)David Herron)【摘要 书评 试读】 京东图书
    PhantomJS in nonheadless mode Google Groups
    Backbone.js
    Underscore.js
    Free HTTP Sniffer: a free HTTP packet sniffer to find the URLs.
    phantomjs node.js parse child process output line by line (spawn) Stack Overflow
    Getting Started · jashkenas/rubyprocessing Wiki
    使用 JSONP 实现跨域通信,第 2 部分: 使用 JSONP、jQuery 和 Yahoo! 查询语言构建 mashup
    JavaScript中的正则表达式
  • 原文地址:https://www.cnblogs.com/fanxiaotian/p/5002667.html
Copyright © 2020-2023  润新知