private void BtnOk_Click(object sender, EventArgs e) { //Hide Cows and Bulls #region Bull1.Hide(); Bull2.Hide(); Bull3.Hide(); Bull4.Hide(); Cow1.Hide(); Cow2.Hide(); Cow3.Hide(); Cow4.Hide(); #endregion //Accept data #region data = System.IO.File.ReadAllLines("data.txt"); num1 = Convert.ToInt32(data[0]); num2 = Convert.ToInt32(data[1]); num3 = Convert.ToInt32(data[2]); num4 = Convert.ToInt32(data[3]); #endregion //Zero #region bull = 0; cow = 0; #endregion //Divide a number (rozdělit na celé císlo) #region int i = Convert.ToInt32(textBox1.Text); int a = i / 1000; int b = (i - (a * 1000)) / 100; int c = ((i - ((a * 1000) + (b * 100))) / 10); int d = (i - ((a * 1000) + (b * 100) + (c * 10))); #endregion //chief code (Hlavni kod) #region if (a == b || a == c || a == d) { MessageBox.Show("Type different numbers"); } else { if (b == a || b == c || b == d) { MessageBox.Show("Type different numbers"); } else { if (c == d || c == b || c == a) { MessageBox.Show("Type different numbers"); } else { //Beyond (Dal) #region //Bulls #region if (a == num2 || a == num3 || a == num4) { bull++; } if (b == num1 || b == num3 || b == num4) { bull++; } if (c == num1 || c == num2 || c == num4) { bull++; } if (d == num1 || d == num2 || d == num3) { bull++; } #endregion //Cow #region if (a == num1) { cow++; } if (b == num2) { cow++; } if (c == num3) { cow++; } if (d == num4) { cow++; } #endregion #endregion } } } #endregion //Show #region //bull #region if (bull == 1) { Bull1.Show(); } if (bull == 2) { Bull1.Show(); Bull2.Show(); } if (bull == 3) { Bull1.Show(); Bull2.Show(); Bull3.Show(); } if (bull == 4) { Bull1.Show(); Bull2.Show(); Bull3.Show(); Bull4.Show(); } #endregion //cow #region if (cow == 1) { Cow1.Show(); } if (cow == 2) { Cow1.Show(); Cow2.Show(); } if (cow == 3) { Cow1.Show(); Cow2.Show(); Cow3.Show(); } if (cow == 4) { Cow1.Show(); Cow2.Show(); Cow3.Show(); Cow4.Show(); if (point == 1) { blabla = "You are lucky! XD"; } else if (point <= 10) { blabla = "Very very good! Nice game! xD"; } else if (point > 10 && point <= 20) { blabla = "Not bad!"; } else if (point > 20) { blabla = "May be better."; } MessageBox.Show("You won! You had " + point.ToString() + " attempts! " + blabla); } #endregion #endregion //Points #region point++; lblPoint.Text = point.ToString(); #endregion }
private void Form1_Load(object sender, EventArgs e) { //Schovat Kravy a Byky #region Bull1.Hide(); Bull2.Hide(); Bull3.Hide(); Bull4.Hide(); Cow1.Hide(); Cow2.Hide(); Cow3.Hide(); Cow4.Hide(); point = 0; lblPoint.Text = point.ToString(); #endregion //Generovani #region //Prvni kroky #region Random rnd = new Random(); num1 = 0; num2 = 0; num3 = 0; num4 = 0; #endregion //Generovani #region num1 = rnd.Next(0, 9); num2 = rnd.Next(0, 9); while (num2 == num1) { num2 = rnd.Next(0, 9); } num3 = rnd.Next(0, 9); while (num3 == num2 || num3 == num1) { num3 = rnd.Next(0, 9); } num4 = rnd.Next(0, 9); while (num4 == num3 || num4 == num2 || num4 == num1) { num4 = rnd.Next(0, 9); } #endregion //Uchovani #region data = new string[] { num1.ToString(), num2.ToString(), num3.ToString(), num4.ToString(), }; System.IO.File.WriteAllLines("data.txt", data); #endregion #endregion }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. int strength = 0; if (Rising(HMA(period1))) { Bull0.Set(3); strength++; } else { Bear0.Set(3); } if (Rising(HMA(period2))) { Bull1.Set(2); strength++; } else { Bear1.Set(2); } if (Rising(HMA(period3))) { Bull2.Set(1); strength++; } else { Bear2.Set(1); } if (Rising(HMA(period4))) { Bull3.Set(0); strength++; } else { Bear3.Set(0); } Print(Time + " strength: " + strength); switch ((int)(strength)) { case 0: SumBearStrong.Set(5); break; case 1: SumBearWeak.Set(5); break; case 2: SumNeutral.Set(5); break; case 3: SumBullWeak.Set(5); break; case 4: SumBullStrong.Set(5); break; default: break; } }