程式設計工藝大師
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
{
int c1 = 0, d1 = 0;
int c2 = 0, d2 = 0;
int c3 = 0, d3 = 0;
int rndmony1 = 100;
int rndmony2 = 100;
int rndmony3 = 100;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
c1 = c1 + 1;
d1 = c1 % 10;
if (c1>= rndmony1) timer1.Enabled = false;
if (d1==0)
{
button1.BackColor = Color.Red;
}
else if (d1 == 1)
{
button1.BackColor = Color.White;
}
else if (d1 == 2)
{
button1.BackColor = Color.White;
}
button1.Text = d1.ToString();
}
private void timer2_Tick(object sender, EventArgs e)
{
c2 = c2 + 1;
d2 = c2 % 10;
if (c2 >= rndmony2) timer2.Enabled = false;
if (d2 ==0)
{
button2.BackColor = Color.Red;
}
else if (d2 == 1)
{
button2.BackColor = Color.White;
}
else if (d2 == 2)
{
button2.BackColor = Color.White;
}
button2.Text = d2.ToString();
}
private void timer3_Tick(object sender, EventArgs e)
{
c3 = c3 + 1;
d3 = c3 % 10;
if (c3 >= rndmony3) timer3.Enabled = false;
if (d3 ==0)
{
button3.BackColor = Color.Red;
}
else if (d3 == 1)
{
button3.BackColor = Color.White;
}
else if (d3 == 2)
{
button3.BackColor = Color.White;
}
button3.Text = d3.ToString();
}
private void button4_Click(object sender, EventArgs e)
{
c1 = 0;
c2 = 0;
c3 = 0;
timer1.Enabled = true;
timer2.Enabled = true;
timer3.Enabled = true;
Random rnd = new Random();
rndmony1 = rnd.Next(1, 101);
rndmony2 = rnd.Next(1, 101);
rndmony3 = rnd.Next(1, 101);
button4.Text = rndmony1.ToString() + rndmony2.ToString()+rndmony3.ToString();
}
}
}
沒有留言:
張貼留言