zoukankan      html  css  js  c++  java
  • 结对编程

    一.需求分析

    1.先设置Form1窗体,向里面添加8个Lable控件,3个TextBox控件,2个Button控件.

    2:在Form2窗体中添加3个Lable控件,3个TextBox控件.

     二.代码

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;

    namespace 
    {
             public partial class Form1 : Form
             {
              public Form1()
              {
                     InitializeComponent();
              }

              public static int Count = 0; 
              public static int right = 0; 

              private void button1_Click(object sender, EventArgs e)
              { 
                      RandomNum();
              } 
              private void RandomNum()
              { 

    Random ran = new Random();
    int n1, n2;
    n1 = ran.Next(1, 11);
    n2 = ran.Next(1, 11);
    textBox1.Text = n1.ToString();
    textBox2.Text = n2.ToString();
    textBox3.Text = "";
    Count++;


              }

    private void textBox3_KeyDown(object sender, KeyEventArgs e)
    {
               int Count;
               string c = label9.Text;
               switch (c)
              { 

    case "+":
    Count = int.Parse(textBox1.Text) + int.Parse(textBox2.Text);
    break;
    case "-":
    Count = int.Parse(textBox1.Text) - int.Parse(textBox2.Text);
    break;
    case "x":
    Count = int.Parse(textBox1.Text) * int.Parse(textBox2.Text);
    break;
    default:
    Count = int.Parse(textBox1.Text) / int.Parse(textBox2.Text);
    break

    }

    if (e.KeyCode == Keys.Enter)
    {
         if (textBox3.Text == Count.ToString())
         right++;
         RandomNum();
    }

      }

    private void label5_Click(object sender, EventArgs e)
    {
           label10.Text = "+";
           RandomNum();
    }

    private void label6_Click(object sender, EventArgs e)
    {
          label10.Text = "-";
          RandomNum();
    }

    private void label7_Click(object sender, EventArgs e)
    {
          label10.Text = "*";
          RandomNum();
    }

    private void label8_Click(object sender, EventArgs e)
    {
           label10.Text = "/";
           RandomNum();
    }

               private void button2_Click_1(object sender, EventArgs e)
              {
                     textBox3.Enabled = false;
                     Form2 frm2 = new Form2();
                      frm2.ShowDialog();
               }

          }
    }

    好友合作:夏静蕊   王书博

  • 相关阅读:
    [NOIP2011] 玛雅游戏
    [bzoj4025] 二分图
    [10.2模拟] tree
    [10.3模拟] color
    [10.2模拟] teach
    [10.2模拟] plan
    [10.2模拟] book
    [bzoj4999] This Problem Is Too Simple!
    [9.28模拟] good
    [bzoj3884] 上帝与集合的正确用法
  • 原文地址:https://www.cnblogs.com/12345wang/p/4890627.html
Copyright © 2011-2022 走看看