结对编程项目——四则运算

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

基本功能要求:dom

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

须要支持的基本设定参数this

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

       

 

学习感觉:spa

以前本身单独进行做业的时候,会碰上不少的困难本身单独解决不了,就会致使做业的上交延误之类的问题,可是经过此次的两人模式(咱们组是三我的进行)搭档来进行编码,我以为在效率上提升了很多,而且对于做业的认真程度,对项目的理解更是深刻了不止一个层次。在进行的过程当中,虽然咱们也遇到了不少的问题,但经过与大神的交流还有本身查阅一些资料,也顺利的解决了问题,可是还有一些题目的要求咱们没有达到要求,以后会继续跟进的。3d

结对队友:于悦 http://www.cnblogs.com/yuyue1216/    丁艺朔  http://www.cnblogs.com/dys123hahabalalacode

 

代码:orm

form 1blog

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();
        }

        
    }
}

 

程序截图: