C#问题,猜拳游戏。如何不经过按钮直接调用resul方法
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Geam
{
public partial class Game : Form
{
public Game()
{
InitializeComponent();
}
int sum;
int shu;
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
if (MessageBox.Show("你确定要退出?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
this.Close();
}
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
label6.Text = "石头";
this.resul();
if (label7.Text == "石头")
{
label5.Text = "平局";
}
else if (label7.Text == "剪刀")
{
label5.Text = "赢";
sum += 1;
label10.Text =""+sum;
}
else
{
label5.Text = "输";
shu += 1;
label9.Text = "" + shu;
}
}
private void button2_Click(object sender, EventArgs e)
{
label6.Text = "剪刀";
this.resul();
if (label7.Text == "石头")
{
label5.Text = "输";
shu += 1;
label9.Text = "" + shu;
}
else if (label7.Text == "剪刀")
{
label5.Text = "平局";
}
else
{
label5.Text = "赢";
sum += 1;
label10.Text = "" + sum;
}
}
private void button3_Click(object sender, EventArgs e)
{
label6.Text = "布";
this.resul();
if (label7.Text == "石头")
{
label5.Text = "赢";
sum += 1;
label10.Text = "" + sum;
}
else if (label7.Text == "剪刀")
{
label5.Text = "输";
shu += 1;
label9.Text = "" +shu;
}
else
{
label5.Text = "平局";
}
}
private void resul()
{
if (sum + shu == 5)
{
if (sum > shu)
{
MessageBox.Show("恭喜你,你赢了!", "提示", MessageBoxButtons.OK);
sum =0;
shu =0;
label9.Text = "";
label10.Text="";
}
else
{
MessageBox.Show("很遗憾,你输了!", "提示", MessageBoxButtons.OK);
sum = 0;
shu =0;
label9.Text = "";
label10.Text = "";
}
}
int j;
Random ran = new Random();
j = ran.Next(3) + 1;
if (j == 1)
{
label7.Text="石头";
}
else if(j==2)
{
label7.Text = "剪刀";
}
else
{
label7.Text = "布";
}
}
private void toolStripMenuItem3_Click(object sender, EventArgs e)
{
Form1 f = new Form1();
f.Show();
}
private void label5_Click(object sender, EventArgs e)
{
}
private void label10_Click(object sender, EventArgs e)
{
}
}
}