程式設計工藝大師
紅綠燈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 c = 0, d = 0;
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
button1.BackColor = Color.WhiteSmoke;
button2.BackColor = Color.WhiteSmoke;
button3.BackColor = Color.WhiteSmoke;
c++;
d = c % 3;
if (d == 1)
{
button1.BackColor = Color.Red;
button2.BackColor = Color.White;
button3.BackColor = Color.White;
}
else if (d == 2)
{
button1.BackColor = Color.White;
button2.BackColor = Color.Yellow;
button3.BackColor = Color.White;
}
else if (d == 0)
{
button1.BackColor = Color.White;
button2.BackColor = Color.White;
button3.BackColor = Color.Green;
}
//button1.Text = c.ToString() ;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
}
}
沒有留言:
張貼留言