public partial class Form1 : Form
{
int c = 0, d=0;
int g = 0, f = 0;
int p = 0, q = 0;
int rndmoney1 = 100;
int rndmoney2 = 100;
int rndmoney3= 100;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
c = c + 1;
d = c % 3;
button1.Text = d.ToString();
if (c >= rndmoney1)
{
timer1.Enabled = false;
}
if (d == 0)
{
//button1.BackColor = System.Drawing.Color.Red;
}
else
{
//button1.BackColor = System.Drawing.Color.White;
}
if (d == 1)
{
//button2.BackColor = System.Drawing.Color.Yellow;
}
else
{
//button2.BackColor = System.Drawing.Color.White;
}
if (d == 2)
{
//button3.BackColor = System.Drawing.Color.Green;
}
else
{
//button3.BackColor = System.Drawing.Color.White;
}
}
private void button4_Click(object sender, EventArgs e)
{
c = 0;
g = 0;
p = 0;
timer1.Enabled = true;
timer2.Enabled = true;
timer3.Enabled = true;
Random rnd = new Random();
rndmoney1 = rnd.Next(1, 11);
rndmoney2 = rnd.Next(1, 11);
rndmoney3 = rnd.Next(1, 11);
button4.Text = rndmoney1.ToString() + rndmoney2.ToString() + rndmoney3.ToString();
}
private void timer2_Tick(object sender, EventArgs e)
{
g= g + 1;
f = g% 3;
button2.Text = f.ToString();
if (g >= rndmoney2)
{
timer2.Enabled = false;
}
if (f == 0)
{
//button1.BackColor = System.Drawing.Color.Red;
}
else
{
//button1.BackColor = System.Drawing.Color.White;
}
if (f == 1)
{
//button2.BackColor = System.Drawing.Color.Yellow;
}
else
{
//button2.BackColor = System.Drawing.Color.White;
}
if (f == 2)
{
//button3.BackColor = System.Drawing.Color.Green;
}
else
{
//button3.BackColor = System.Drawing.Color.White;
}
}
private void timer3_Tick(object sender, EventArgs e)
{
p = p + 1;
q = p % 3;
button3.Text = q.ToString();
if (p >= rndmoney3)
{
timer3.Enabled = false;
}
if (q == 0)
{
//button1.BackColor = System.Drawing.Color.Red;
}
else
{
//button1.BackColor = System.Drawing.Color.White;
}
if (q == 1)
{
//button2.BackColor = System.Drawing.Color.Yellow;
}
else
{
//button2.BackColor = System.Drawing.Color.White;
}
if (q == 2)
{
//button3.BackColor = System.Drawing.Color.Green;
}
else
{
//button3.BackColor = System.Drawing.Color.White;
}
}
private void timer4_Tick(object sender, EventArgs e)
{
button4.Text = "start";
if(d==f && f==q && q==d)
{
button5.Text="Win";
}
else
{
button5.Text="Lose";
}
}
private void button5_Click(object sender, EventArgs e)
{
}
}
}