Facebook
From Sloppy Agouti, 3 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 119
  1. #pragma endregion
  2.                 int numer;
  3.                 int guess;
  4.                 int strzal = 0;
  5.                
  6.         public: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  7.                 numer = rand() % 100 + 1;
  8.                 liczbaBox->Enabled = true;
  9.                
  10.                
  11.                
  12.         }
  13.         private: System::Void zgadnijBtn_Click(System::Object^  sender, System::EventArgs^  e) {
  14.                
  15.                 try
  16.                 {
  17.  
  18.                         guess = Int32::Parse(liczbaBox->Text);
  19.  
  20.                         if (guess<numer)
  21.                         {
  22.                                 czyZgadleslbl->Text = "Tak mało? Jak tak dalej pójdzie to nigdy nie zgadniesz tego numeru...";
  23.                                 strzal++;
  24.                         }
  25.                         else if (guess>numer)
  26.                         {
  27.                                 czyZgadleslbl->Text = "Niestety nie trafiłeś!Przestrzeliłeś, próbuj dalej...";
  28.                                 strzal++;
  29.                         }
  30.  
  31.                         else if (guess == numer)
  32.                         {
  33.                                 czyZgadleslbl->Text = "To git";
  34.                                 strzal++;
  35.                                 czyZgadleslbl->Text = "W końcu Ci się udało!";
  36.                                 MessageBox::Show("Udało Ci się odgadnąć liczbę! Zajęło Ci to " + strzal.ToString() + " prób.", "Gratulacje", MessageBoxButtons::YesNo, MessageBoxIcon::Information);
  37.  
  38.                         }
  39.                 }
  40.                 catch (FormatException^ e)
  41.                 {
  42.  
  43.                 }
  44.        
  45.  
  46.        
  47.                
  48.         }
  49. private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
  50.         try
  51.         {
  52.                 guess = Int32::Parse(liczbaBox->Text);
  53.         }
  54.         catch (FormatException^ e)
  55.         {
  56.  
  57.         }
  58. }
  59. private: System::Void powrotBtn_Click(System::Object^  sender, System::EventArgs^  e) {
  60.         Close();
  61. }
  62. };
  63. }
  64.