⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 大话设计模式源码bigtalkdesignpattern_src
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OperationLibrary;

namespace 计算器
{
    /// <summary>
    /// 面向对象编程
    /// 1、加运算类
    /// 2、加运算子类
    /// 3、加运算类工厂
    /// 4、更改Form1
    public partial class Form1 : Form
    {
        bool bOperate = false;
        Operation oper;

        public Form1()
        {
            InitializeComponent();
        }

        private void button0_Click(object sender, EventArgs e)
        {
            if (bOperate)
            {
                txtShow.Text = "";
                bOperate = false;
            }
            
            string number = ((Button)sender).Text;

            txtShow.Text = Operation.checkNumberInput(txtShow.Text, number);
            
        }

        private void buttonClear_Click(object sender, EventArgs e)
        {
            txtShow.Text = "";
        }

        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (txtShow.Text != "")
            {
                oper = OperationFactory.createOperate(((Button)sender).Text);
                
                oper.NumberA = Convert.ToDouble(txtShow.Text);
                
                bOperate = true;
            }
        }

        private void buttonEqual_Click(object sender, EventArgs e)
        {
            if (txtShow.Text != "")
            {
                if (((Button)sender).Text != "=")
                {
                    oper = OperationFactory.createOperate(((Button)sender).Text);
                }
                
                oper.NumberB = Convert.ToDouble(txtShow.Text);

                
                txtShow.Text = oper.GetResult().ToString();
                bOperate = true;
            }
        }

 
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -