Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <string>
- namespace CppCLRWinformsProjekt {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- using namespace std;
- int number = 1;
- int wynik = 0;
- public ref class Form1 : public System::Windows::Forms::Form
- {
- public:
- Form1(void)
- {
- InitializeComponent();
- }
- protected:
- ~Form1()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::Button^ button1;
- protected:
- private: System::Windows::Forms::Button^ button2;
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::RadioButton^ radioButton1;
- private: System::Windows::Forms::RadioButton^ radioButton2;
- private: System::Windows::Forms::RadioButton^ radioButton3;
- private: System::Windows::Forms::RadioButton^ radioButton4;
- private: System::Windows::Forms::Button^ button3;
- private:
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- void InitializeComponent(void)
- {
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->button2 = (gcnew System::Windows::Forms::Button());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());
- this->radioButton2 = (gcnew System::Windows::Forms::RadioButton());
- this->radioButton3 = (gcnew System::Windows::Forms::RadioButton());
- this->radioButton4 = (gcnew System::Windows::Forms::RadioButton());
- this->button3 = (gcnew System::Windows::Forms::Button());
- this->SuspendLayout();
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(424, 25);
- this->button1->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(112, 35);
- this->button1->TabIndex = 0;
- this->button1->Text = L"Poprzednie";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
- //
- // button2
- //
- this->button2->Location = System::Drawing::Point(546, 22);
- this->button2->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->button2->Name = L"button2";
- this->button2->Size = System::Drawing::Size(112, 35);
- this->button2->TabIndex = 1;
- this->button2->Text = L"Następne";
- this->button2->UseVisualStyleBackColor = true;
- this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(238)));
- this->label1->Location = System::Drawing::Point(20, 20);
- this->label1->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(152, 33);
- this->label1->TabIndex = 2;
- this->label1->Text = L"Pytanie #1";
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
- static_cast<System::Byte>(238)));
- this->label2->Location = System::Drawing::Point(20, 98);
- this->label2->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(352, 33);
- this->label2->TabIndex = 3;
- this->label2->Text = L"Kliknij aby poznać pytanie";
- this->label2->Click += gcnew System::EventHandler(this, &Form1::label2_Click);
- //
- // radioButton1
- //
- this->radioButton1->AutoSize = true;
- this->radioButton1->Location = System::Drawing::Point(36, 174);
- this->radioButton1->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->radioButton1->Name = L"radioButton1";
- this->radioButton1->Size = System::Drawing::Size(125, 24);
- this->radioButton1->TabIndex = 4;
- this->radioButton1->TabStop = true;
- this->radioButton1->Text = L"odpowiedź A";
- this->radioButton1->UseVisualStyleBackColor = true;
- this->radioButton1->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton1_CheckedChanged);
- //
- // radioButton2
- //
- this->radioButton2->AutoSize = true;
- this->radioButton2->Location = System::Drawing::Point(36, 209);
- this->radioButton2->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->radioButton2->Name = L"radioButton2";
- this->radioButton2->Size = System::Drawing::Size(125, 24);
- this->radioButton2->TabIndex = 5;
- this->radioButton2->TabStop = true;
- this->radioButton2->Text = L"odpowiedź B";
- this->radioButton2->UseVisualStyleBackColor = true;
- //
- // radioButton3
- //
- this->radioButton3->AutoSize = true;
- this->radioButton3->Location = System::Drawing::Point(36, 245);
- this->radioButton3->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->radioButton3->Name = L"radioButton3";
- this->radioButton3->Size = System::Drawing::Size(125, 24);
- this->radioButton3->TabIndex = 6;
- this->radioButton3->TabStop = true;
- this->radioButton3->Text = L"odpowiedź C";
- this->radioButton3->UseVisualStyleBackColor = true;
- //
- // radioButton4
- //
- this->radioButton4->AutoSize = true;
- this->radioButton4->Location = System::Drawing::Point(34, 280);
- this->radioButton4->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->radioButton4->Name = L"radioButton4";
- this->radioButton4->Size = System::Drawing::Size(126, 24);
- this->radioButton4->TabIndex = 7;
- this->radioButton4->TabStop = true;
- this->radioButton4->Text = L"odpowiedź D";
- this->radioButton4->UseVisualStyleBackColor = true;
- //
- // button3
- //
- this->button3->Location = System::Drawing::Point(36, 335);
- this->button3->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->button3->Name = L"button3";
- this->button3->Size = System::Drawing::Size(112, 35);
- this->button3->TabIndex = 8;
- this->button3->Text = L"OK";
- this->button3->UseVisualStyleBackColor = true;
- this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
- //
- // Form1
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(9, 20);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(681, 512);
- this->Controls->Add(this->button3);
- this->Controls->Add(this->radioButton4);
- this->Controls->Add(this->radioButton3);
- this->Controls->Add(this->radioButton2);
- this->Controls->Add(this->radioButton1);
- this->Controls->Add(this->label2);
- this->Controls->Add(this->label1);
- this->Controls->Add(this->button2);
- this->Controls->Add(this->button1);
- this->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
- this->Name = L"Form1";
- this->Text = L"Quiz Matematyczny by Zuzanna Prościak";
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void label2_Click(System::Object^ sender, System::EventArgs^ e) {
- if (number == 1) {
- label2->Text = "Jaki jest wynik działania 2 + 2 * 2";
- radioButton1->Text = "4";
- radioButton2->Text = "2";
- radioButton3->Text = "6"; //poprawna odp
- radioButton4->Text = "10";
- }
- if (number == 2) {
- label2->Text = "Wynik działania 2 + 2 + 4 * 4 to";
- radioButton1->Text = "20";//poprawna odp
- radioButton2->Text = "32";
- radioButton3->Text = "28";
- radioButton4->Text = "36";
- }
- if (number == 3) {
- label2->Text = "Ile wynosi pole kwadratu o boku 1,5cm?";
- radioButton1->Text = "1,25cm^2";
- radioButton2->Text = "1,75cm^2";
- radioButton3->Text = "2,25cm^2";//poprawna odp
- radioButton4->Text = "3,5cm^2";
- }
- if (number == 4) {
- label2->Text = "Cegła waży 2kg i pół cegły. Ile waży cegła?";
- radioButton1->Text = "4 kg";//poprawna odp
- radioButton2->Text = "2 kg";
- radioButton3->Text = "6 kg";
- radioButton4->Text = "10 kg";
- }
- if (number == 5) {
- label2->Text = "Jeśli x = 6 - 2x, ile wynosi x?";
- radioButton1->Text = "3";
- radioButton2->Text = "-6";
- radioButton3->Text = "4";
- radioButton4->Text = "2";//poprawna odp
- }
- if (number == 6) {
- label2->Text = "Wynik działania 7 * 77 to: ";
- radioButton1->Text = "495";
- radioButton2->Text = "539";//poprawna odp
- radioButton3->Text = "620";
- radioButton4->Text = "449";
- }
- if (number == 7) {
- label2->Text = "Wynik działania 19 + 5 * 2 - 16 + 3 * 1 to: ";
- radioButton1->Text = "48";
- radioButton2->Text = "16";//poprawna odp
- radioButton3->Text = "35";
- radioButton4->Text = "8";
- }
- if (number == 8) {
- label2->Text = "Wynik wyrażenia 3 do sześcianu to: ";
- radioButton1->Text = "27";//poprawna odp
- radioButton2->Text = "9";
- radioButton3->Text = "81";
- radioButton4->Text = "5";
- }
- if (number == 9) {
- label2->Text = "Wynik wyrażenia (-9)-(-23) to: ";
- radioButton1->Text = "32";
- radioButton2->Text = "14";//poprawna odp
- radioButton3->Text = "-14";
- radioButton4->Text = "-32";
- }
- if (number == 10) {
- label2->Text = "Jeżeli a = -2, b = 2, c = 3,14 oblicz b * c - a";
- radioButton1->Text = "8,28";//poprawna odp
- radioButton2->Text = "6,14";
- radioButton3->Text = "-4,14";
- radioButton4->Text = "0";
- }
- }
- private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
- if (number == 1) {
- if (radioButton1->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton2->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton3->Checked) {
- MessageBox::Show("Odpowiedź poprawna + 1 pkt");
- wynik += 1;
- }
- if (radioButton4->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- }
- if (number == 2) {
- if (radioButton1->Checked) {
- MessageBox::Show("Odpowiedź poprawna + 1 pkt");
- wynik += 1;
- }
- if (radioButton2->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton3->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton4->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- }
- if (number == 3) {
- if (radioButton1->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton2->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton3->Checked) {
- MessageBox::Show("Odpowiedź poprawna + 1 pkt");
- wynik += 1;
- }
- if (radioButton4->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- }
- if (number == 4) {
- if (radioButton1->Checked) {
- MessageBox::Show("Odpowiedź poprawna + 1 pkt");
- wynik += 1;
- }
- if (radioButton2->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton3->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton4->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- }
- if (number == 5) {
- if (radioButton1->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton2->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton3->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton4->Checked) {
- MessageBox::Show("Odpowiedź poprawna + 1 pkt");
- wynik += 1;
- }
- }
- if (number == 6) {
- if (radioButton1->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton2->Checked) {
- MessageBox::Show("Odpowiedź poprawna + 1 pkt");
- wynik += 1;
- }
- if (radioButton3->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton4->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- }
- if (number == 7) {
- if (radioButton1->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton2->Checked) {
- MessageBox::Show("Odpowiedź poprawna + 1 pkt");
- wynik += 1;
- }
- if (radioButton3->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton4->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- }
- if (number == 8) {
- if (radioButton1->Checked) {
- MessageBox::Show("Odpowiedź poprawna + 1 pkt");
- wynik += 1;
- }
- if (radioButton2->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton3->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton4->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- }
- if (number == 9) {
- if (radioButton1->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton2->Checked) {
- MessageBox::Show("Odpowiedź poprawna + 1 pkt");
- wynik += 1;
- }
- if (radioButton3->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton4->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- }
- if (number == 10) {
- if (radioButton1->Checked) {
- MessageBox::Show("Odpowiedź poprawna + 1 pkt");
- wynik += 1;
- }
- if (radioButton2->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton3->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- if (radioButton4->Checked) {
- MessageBox::Show("Odpowiedź niepoprawna");
- }
- MessageBox::Show("Twój wynik quizu " + wynik + " na 10 możliwych", "Wynik");
- }
- }
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
- number++;
- label1->Text = "Pytanie #" + number;
- label2->Text = "Kliknij aby poznać pytanie";
- radioButton1->Text = "odpowiedź A";
- radioButton2->Text = "odpowiedź B";
- radioButton3->Text = "odpowiedź C";
- radioButton4->Text = "odpowiedź D";
- radioButton1->Checked = false;
- radioButton2->Checked = false;
- radioButton3->Checked = false;
- radioButton4->Checked = false;
- if (number >= 10) {
- MessageBox::Show("Dziesiąte pytanie jest ostatnie!");
- number = 10;
- label1->Text = "Pytanie #" + number;
- }
- }
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- number--;
- label1->Text = "Pytanie #" + number;
- label2->Text = "Kliknij aby poznać pytanie";
- radioButton1->Text = "odpowiedź A";
- radioButton2->Text = "odpowiedź B";
- radioButton3->Text = "odpowiedź C";
- radioButton4->Text = "odpowiedź D";
- radioButton1->Checked = false;
- radioButton2->Checked = false;
- radioButton3->Checked = false;
- radioButton4->Checked = false;
- if (number <= 1) {
- MessageBox::Show("Aktualnie cofnięto do pierwszego pytania!");
- number = 1;
- label1->Text = "Pytanie #" + number;
- }
- }
- private: System::Void radioButton1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement