结对编程
2015-10-18 22:56
211 查看
[b]需求分析[/b]
[b]设置Form1窗体,向里面添加8个Lable控件,3个TextBox控件,2个Button控件[/b]
·代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
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();
}
}
}
四·好友合作:夏静蕊 王书博
[b]设置Form1窗体,向里面添加8个Lable控件,3个TextBox控件,2个Button控件[/b]
·代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
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();
}
}
}
四·好友合作:夏静蕊 王书博
相关文章推荐
- STL之hashtable实现
- Python(七)python下的内部函数库和第三方函数库
- 交换两个数内容,无临时变量(初)
- MFC编程学习之改变对话框和控件及文本颜色
- Python笔记——数字及数学函数
- Java基础---多线程
- Python笔记——基本控制流
- Python笔记——基本语法:标识符、数据类型、变量、运算符及表达式/编码风格
- Python笔记——python简介、特点、安装及helloworld
- 【C++】读取循环数字和cin的利用
- Python——类、实例和其他对象的内建函数
- Python——类属性/实例属性
- Python——面向对象编程(引言)
- 30分钟快速搭建Web CRUD的管理平台--django神奇魔法
- Python——条件、循环和其他语句
- Python——字典
- Python——字符串
- eclipse 关联javadoc文档和源码
- Python——序列
- Python基础:__name__