#pragma once
#include <cstdlib>
namespace ProgramZaliczeniowy {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for zgadnijNumer
/// </summary>
public ref class zgadnijNumer : public System::Windows::Forms::Form
{
public:
zgadnijNumer(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~zgadnijNumer()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Label^ czyZgadleslbl;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(zgadnijNumer::typeid));
this->button1 = (gcnew System::Windows::Forms::Button());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->button2 = (gcnew System::Windows::Forms::Button());
this->czyZgadleslbl = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// button1
//
this->button1->BackColor = System::Drawing::Color::Transparent;
this->button1->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"button1.BackgroundImage")));
this->button1->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
this->button1->FlatAppearance->BorderSize = 0;
this->button1->FlatAppearance->MouseDownBackColor = System::Drawing::Color::Transparent;
this->button1->FlatAppearance->MouseOverBackColor = System::Drawing::Color::Transparent;
this->button1->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
this->button1->Font = (gcnew System::Drawing::Font(L"Buxton Sketch", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->button1->ForeColor = System::Drawing::SystemColors::Info;
this->button1->Location = System::Drawing::Point(47, 305);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(101, 52);
this->button1->TabIndex = 0;
this->button1->Text = L"NEW NUMBER";
this->button1->UseVisualStyleBackColor = false;
this->button1->Click += gcnew System::EventHandler(this, &zgadnijNumer::button1_Click);
//
// textBox1
//
this->textBox1->Enabled = false;
this->textBox1->Location = System::Drawing::Point(47, 114);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(101, 20);
this->textBox1->TabIndex = 3;
this->textBox1->TextChanged += gcnew System::EventHandler(this, &zgadnijNumer::textBox1_TextChanged);
//
// button2
//
this->button2->BackColor = System::Drawing::Color::Transparent;
this->button2->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"button2.BackgroundImage")));
this->button2->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
this->button2->FlatAppearance->BorderSize = 0;
this->button2->FlatAppearance->MouseDownBackColor = System::Drawing::Color::Transparent;
this->button2->FlatAppearance->MouseOverBackColor = System::Drawing::Color::Transparent;
this->button2->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
this->button2->Font = (gcnew System::Drawing::Font(L"Buxton Sketch", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->button2->ForeColor = System::Drawing::SystemColors::Info;
this->button2->Location = System::Drawing::Point(47, 155);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(101, 49);
this->button2->TabIndex = 4;
this->button2->Text = L"GUESS";
this->button2->UseVisualStyleBackColor = false;
this->button2->Click += gcnew System::EventHandler(this, &zgadnijNumer::button2_Click);
//
// czyZgadleslbl
//
this->czyZgadleslbl->BackColor = System::Drawing::Color::Transparent;
this->czyZgadleslbl->Font = (gcnew System::Drawing::Font(L"Buxton Sketch", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->czyZgadleslbl->Location = System::Drawing::Point(360, 132);
this->czyZgadleslbl->Name = L"czyZgadleslbl";
this->czyZgadleslbl->Size = System::Drawing::Size(100, 23);
this->czyZgadleslbl->TabIndex = 5;
this->czyZgadleslbl->Text = L"...";
this->czyZgadleslbl->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
//
// zgadnijNumer
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"$this.BackgroundImage")));
this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
this->ClientSize = System::Drawing::Size(549, 459);
this->Controls->Add(this->czyZgadleslbl);
this->Controls->Add(this->button2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->button1);
this->DoubleBuffered = true;
this->MaximizeBox = false;
this->Name = L"zgadnijNumer";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"Guess The Number";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
int numer;
int guess;
int strzal = 0;
public: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
numer = rand() % 100 + 1;
textBox1->Enabled = true;
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
guess = Int32::Parse(textBox1->Text);
if (guess<numer)
{
czyZgadleslbl->Text = "To za mało";
strzal++;
}
else if (guess>numer)
{
czyZgadleslbl->Text = "To za dużo";
strzal++;
}
else if (guess == numer)
{
czyZgadleslbl->Text = "To git";
strzal++;
MessageBox::Show("Udało Ci się odgadnąć liczbę! Zajęło Ci to " + strzal.ToString() + " prób.", "Gratulacje", MessageBoxButtons::YesNo,MessageBoxIcon::Information );
}
}
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
guess = Int32::Parse(textBox1->Text);
}
};
}