您的位置:首页 > 其它

猜数小游戏

2016-12-04 18:45 155 查看
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
{
public Form1()
{
InitializeComponent();
}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}
public int shu() {
Random r = new Random();
int i=  r.Next(1, 100);

return i;

}
int b = 0;
private void button1_Click(object sender, EventArgs e)
{
this.textBox2.Text = shu().ToString();

b = 0;
//MessageBox.Show("a", "提--示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button2_Click(object sender, EventArgs e)
{

b++;
if (this.textBox1.Text.Equals(this.textBox2.Text))
{

MessageBox.Show("恭喜你猜对了", "提--示用了" + b + "遍", MessageBoxButtons.OK, MessageBoxIcon.Information);

}
else if (int.Parse(this.textBox1.Text) > int.Parse(this.textBox2.Text))
{
MessageBox.Show("再小一点", "提--示用了" + b + "遍", MessageBoxButtons.OK, MessageBoxIcon.Information);

}
else if (int.Parse(this.textBox1.Text) < int.Parse(this.textBox2.Text)) { MessageBox.Show("再大一点", "提--示用了" + b + "遍", MessageBoxButtons.OK, MessageBoxIcon.Information); }

}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: