博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
结对编程项目——四则运算
阅读量:4543 次
发布时间:2019-06-08

本文共 4214 字,大约阅读时间需要 14 分钟。

1. 结对编程项目---四则运算 (10分)

基本功能要求:

1) 实现一个带有用户界面的四则运算。2) 生成的题目不能重复。3) 支持负数,例如-1,-1/2,-3‘4/5等。(达成)

需要支持的基本设定参数

1) 题目的数量  2) 数值的范围  3) 题目中最多几个运算符(目前没有达成)  4) 题目中或运算过程中有无有分数(比如进行整数除法的时候不能除尽) 5) 题目中是否有乘除法  6) 题目中是否有括号 (目前没有达成) 7) 题目中或运算过程中有无负数

       

 

学习感受:

之前自己单独进行作业的时候,会碰上很多的困难自己单独解决不了,就会导致作业的上交延误之类的问题,但是通过这次的两人模式(我们组是三个人进行)搭档来进行编码,我觉得在效率上提高了不少,并且对于作业的认真程度,对项目的理解更是深入了不止一个层次。在进行的过程中,虽然我们也遇到了很多的问题,但通过与大神的交流还有自己查阅一些资料,也顺利的解决了问题,但是还有一些题目的要求我们没有达到要求,之后会继续跟进的。

结对队友:于悦     丁艺朔  

 

代码:

form 1

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;namespace WindowsFormsApplication2{    public partial class Form1 : Form    {        Form2 form2;        public Form1()        {            InitializeComponent();            form2 = new Form2();        }        private void button0_Click(object sender, EventArgs e)        {            String name = this.textBox0.Text; // 获取里面的值            String password = this.textBox0.Text;            if (name.Equals("admin") && password.Equals("admin")) // 判断账号密码是否等于admin            {                MessageBox.Show("登录成功");                form2.ShowDialog();            }            else            {                MessageBox.Show("登录失败!");            }                    }    }}

 

  

 form 2

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;namespace WindowsFormsApplication2{    public partial class Form2 : Form    {        int n, r1,r2,ysf;                Form3 form3;        public Form2()        {            InitializeComponent();                    }        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)        {            comboBox1.Text = comboBox1.SelectedItem.ToString();                   }        private void button1_Click(object sender, EventArgs e)        {            Random ran = new Random();            n = Convert.ToInt32(comboBox1.Text.ToString());            r1 = int.Parse(textBox1.Text);            r2 = int.Parse(textBox2.Text);            if(comboBox2.SelectedItem.ToString() == "包含")            {                ysf = 4;            }            else            {                ysf = 2;            }            form3 = new Form3(n, r1, r2, ysf);            form3.ShowDialog();        }        private void button2_Click(object sender, EventArgs e)        {            this.Dispose();        }    }}

 

form 3

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;namespace WindowsFormsApplication2{    public partial class Form3 : Form    {        char[] fuhao = { '+', '-', '*', '%' };        int n, r1, r2, ysf;                public Form3(int n, int r1, int r2, int ysf)        {            InitializeComponent();            this.n = n;            this.r1 = r1;            this.r2 = r2;            this.ysf = ysf;            Form4 form4 = new Form4();        }        private void button1_Click(object sender, EventArgs e)        {            listBox1.Items.Clear();        }        private void button5_Click(object sender, EventArgs e)        {            Application.Exit();        }        private void button3_Click(object sender, EventArgs e)        {            string t = "";                        Random ran   = new Random();            for (int i = 0; i < n; i++)            {                int num1 = ran.Next(r1, r2);                int num2 = ran.Next(r1, r2);                if(ysf == 2)                {                    t = num1 + fuhao[ran.Next(2)].ToString() + num2 + "=";                }                else                {                    t = num1 + fuhao[ran.Next(4)].ToString() + num2 + "=";                }                listBox1.Items.Add(t);            }                    }        private void button4_Click(object sender, EventArgs e)        {            this.Close();        }            }}

 

程序截图:

    

 

转载于:https://www.cnblogs.com/896702797-qw/p/5361252.html

你可能感兴趣的文章
CSS选择符
查看>>
[Win32]一个调试器的实现(六)显示源代码
查看>>
play!:安装以及创建项目
查看>>
Elasticsearch学习之深入聚合分析二---案例实战
查看>>
angularjs中的事件传播$emit,$broadcast,$on
查看>>
LOG4J
查看>>
Centos7 进入单用户模式,修复系统
查看>>
DataGridView列头checkbox 分类: .NET ...
查看>>
hutacm 1465错排
查看>>
.NET开源项目
查看>>
Ceph中Bufferlist的设计与使用
查看>>
左右浮动 三列布局
查看>>
mysql replication 复制的一些问题
查看>>
华为综合面被刷,写点经验,以备后用
查看>>
F-basic资源
查看>>
django的orm框架(进阶篇)
查看>>
js实现跨平台滑动加载
查看>>
win 10 slmgr.vbs -xpr 无法运行,被豆麦笔记打开解决方法
查看>>
CYQ学习主要摘要
查看>>
04 shell编程之循环语句
查看>>