• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

刘小淇

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

作业4

#结对编程项目——四则运算
对于四则运算项目基本的功能要求:
这次,冯老师给我们的作业要求主要有以下几点:
1.实现一个带有用户界面的四则运算
2.对运算题目的数量做出限制
3.对运算题目的数值范围做出限制
4.对运算题目的有无乘除法做出限制(暂未完成)
我们经过自己组内不断的钻研努力,终于基本完成了这个项目

##伙伴信息:

计科13级1班 刘维淇 130201111

计科13级1班 马亚坤 130201136

##题型设定
```
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;
        
        Form2 form2;
        public Form1()
        {
            InitializeComponent();
            
        }


        private void button1_Click(object sender, EventArgs e)
        {
            Random ran = new Random();
            n = Convert.ToInt32(comboBox1.Text.ToString());
            r1 = int.Parse(xiaxian.Text);
            r2 = int.Parse(shangxian.Text);
            if(comboBox2.SelectedItem.ToString() == "包含")
            {
                ysf = 4;
            }
            else
            {
                ysf = 2;
            }
            form2 = new Form3(n, r1, r2, ysf);
            form2.ShowDialog();
        }


        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox1.Text = comboBox1.SelectedItem.ToString();
           
        }

    }
}
```




##出题界面
```
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 Form2(int n, int r1, int r2, int ysf)
        {
            InitializeComponent();
            this.n = n;
            this.r1 = r1;
            this.r2 = r2;
            this.ysf = ysf;
            Form3 form3 = new Form3();
        }

        private void star_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
        }

        private void clear_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void back_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 end_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        
    }
}
```



##程序运行截图:

 

##讨论图片:

 

##总结

这次的题目对于我和马亚坤(同组成员)来说,实在是有些困难。总共两周的时间,我们两个人从找代码去模仿,读懂别人所完成的代码。到自己去制作这个软件,着实下了不少的功夫。但是幸好是结对学习,我俩能互相帮助,一同来完成这个题目。俗话说的好,三个臭皮匠顶个诸葛亮。人多了绝对不是1+1等于2的问题。在编程方面而言,两个人加起来的力量绝对远超两个单独的个体。互相查错,共同学习进步,取长补短。这也许是这次作业交给我们的最重要的东西了吧。自己单独的时候的确容易懒惰,但是需要完成一份共同作业的时候就没法偷懒了。哪怕是现学,也不好意思什么都不做去坐享其成。感谢这次作业让我收获良多。

 

posted on 2016-04-07 09:41  刘小淇  阅读(193)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3