La imagen básica
código del núcleo
1 usando System; 2 usando System.Collections.Generic; 3 usando System.ComponentModel; 4 utilizando System.Data; 5 usando System.Drawing; 6 usando System.Linq; 7 usando System.Text; 8 utilizando System.Threading.Tasks; 9 utilizando System.Windows.Forms; 10 11 espacio de nombres WindowsFormsApp1 12 { 13 pública parcial de la clase Form1: Formulario 14 { 15 pública Form1 () 16 { 17 InitializeComponent (); 18 } 19 int flag = - 1 ; 20 int D1 = - 1 , D2 = - 1 , D3 = - 1 ; 21 privado void Button1_Click ( objeto remitente, EventArgs e) 22 { 23 flag ++ ; 24 Si (bandera == 0 ) 25 { 26 Timer1.Enabled =verdadera ; 27 timer2.Enabled = verdadero ; 28 timer3.Enabled = verdadero ; 29 } 30 más si (bandera == 1 ) 31 { 32 timer1.Stop (); 33 Text = D1.ToString (); 34 } 35 más si (bandera == 2 ) 36 { 37 timer2.Stop (); 38 = textoD1.ToString (); 39 } 40 más si (bandera == 3 ) 41 { 42 timer3.Stop (); 43 Text = D1.ToString (); 44 } 45 más 46 { 47 48 int t = D1 * 100 + D2 * 10 + D3; 49 Text = t.ToString (); 50 si (t == 111 ) 51 { 52 MessageBox.Show ( " Manzana " , " 获奖" , MessageBoxButtons.OK); 53 } más si (t == 222 ) 54 { 55 MessageBox.Show ( " limón " , " 获奖" , MessageBoxButtons.OK); 56 } más si (t == 333 ) 57 { 58 MessageBox.Show ( " Grape" " Ganar "MessageBoxButtons.OK); 59 } 60 el otro 61 es { 62 es MessageBox.Show ( " lo siento " " no ganadores " , MessageBoxButtons.OK); 63 es } 64 En Flag = - 1. ; 65 timer1.Start ( ); 66 timer2.Start (); 67 timer3.Start (); 68 } 69 } 70 71 privada vacío timer1_Tick ( objeto emisor, EventArgs e) 72 { 73 aleatorio RAND = nueva Random (); 74 int k = rand.Next ( 3 ); 75 interruptor (k) 76 { 77 caso 0 : 78 PictureBox1.Image = Properties.Resources.apple; 79 descanso ; 80 caso 1 : 81 PictureBox1.Image = Properties.Resources.lemon; 82 descanso ; 83 caso 2 : 84 PictureBox1.Image = Properties.Resources.grape; 85 descanso ; 86 } 87 D1 = k + 1 ; 88 } 89 90 privada vacío timer2_Tick ( objeto emisor, EventArgs e) 91 { 92 aleatorio RAND = nueva Random (); 93 int k = rand.Next ( 3 ); 94 interruptor (k) 95 { 96 caso 0 : 97 pictureBox2.Image = Properties.Resources.apple; 98 descanso ; 99 caso 1 : 100 pictureBox2.Image = Properties.Resources.lemon; 101 descanso ; 102 caso 2 : 103 pictureBox2.Image = Properties.Resources.grape; 104 descanso ; 105 } 106 D2 = k + 1 ; 107 } 108 109 privada vacío timer3_Tick ( objeto emisor, EventArgs e) 110 { 111 aleatorio RAND = nueva Random (); 112 int k = rand.Next ( 3 ); 113 interruptor (k) 114 { 115 caso 0 : 116 pictureBox3.Image = Properties.Resources.apple; 117 descanso ; 118 caso 1 : 119 pictureBox3.Image =Properties.Resources.lemon; 120 descanso ; 121 caso 2 : 122 pictureBox3.Image = Properties.Resources.grape; 123 descanso ; 124 } 125 D3 = k + 1 ; 126 } 127 } 128 }
representaciones