01 简单工厂模式/计算器窗体/Form1.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OperationLibrary;
namespace 计算器窗体
{
/// <summary>
/// 面向对象编程
/// 1、加运算类
/// 2、加运算子类
/// 3、加运算类工厂
/// 4、更改Form1
/// </summary>
public partial class Form1 : Form
{
Operation oper;
bool bOpertion = false; //指示是否按了运算符
public Form1()
{
InitializeComponent();
}
//数字键和.
private void button0_Click(object sender, EventArgs e)
{
if(bOpertion ) //如果已输入了运算符。则文本框清空。
{
txtShow.Text = "";
bOpertion = false;
}
string number = ((Button)sender).Text;
txtShow.Text = Operation.checkNumberInput(txtShow.Text, number);
}
//加减乘除
private void buttonAdd_Click(object sender, EventArgs e)
{
if (txtShow.Text != "")
{
oper =OperationFactory.createOperation(((Button)sender).Text);
oper.NumberA = Convert.ToDouble(txtShow.Text);
bOpertion = true;
}
}
//开方 平方 取反 等于
private void buttonEqual_Click(object sender, EventArgs e)
{
if (txtShow.Text != "")
{
if (((Button)sender).Text != "=")
{
oper = OperationFactory.createOperation(((Button)sender).Text);
}
oper.NumberB = Convert.ToDouble(txtShow.Text);//单目运算,只考虑NumberB
后面还有 13 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。