Advertisement
peterzig

[C++] Quiz 10 pytań CLR

May 17th, 2020
1,945
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 14.94 KB | None | 0 0
  1. #pragma once
  2. #include <string>
  3.  
  4. namespace CppCLRWinformsProjekt {
  5.  
  6.     using namespace System;
  7.     using namespace System::ComponentModel;
  8.     using namespace System::Collections;
  9.     using namespace System::Windows::Forms;
  10.     using namespace System::Data;
  11.     using namespace System::Drawing;
  12.     using namespace std;
  13.  
  14.     int number = 1;
  15.     int wynik = 0;
  16.    
  17.  
  18.     public ref class Form1 : public System::Windows::Forms::Form
  19.     {
  20.     public:
  21.         Form1(void)
  22.         {
  23.             InitializeComponent();
  24.            
  25.         }
  26.  
  27.     protected:
  28.        
  29.         ~Form1()
  30.         {
  31.             if (components)
  32.             {
  33.                 delete components;
  34.             }
  35.         }
  36.     private: System::Windows::Forms::Button^ button1;
  37.     protected:
  38.     private: System::Windows::Forms::Button^ button2;
  39.     private: System::Windows::Forms::Label^ label1;
  40.     private: System::Windows::Forms::Label^ label2;
  41.     private: System::Windows::Forms::RadioButton^ radioButton1;
  42.     private: System::Windows::Forms::RadioButton^ radioButton2;
  43.     private: System::Windows::Forms::RadioButton^ radioButton3;
  44.     private: System::Windows::Forms::RadioButton^ radioButton4;
  45.     private: System::Windows::Forms::Button^ button3;
  46.  
  47.     private:
  48.        
  49.         System::ComponentModel::Container ^components;
  50.  
  51. #pragma region Windows Form Designer generated code
  52.        
  53.         void InitializeComponent(void)
  54.         {
  55.             this->button1 = (gcnew System::Windows::Forms::Button());
  56.             this->button2 = (gcnew System::Windows::Forms::Button());
  57.             this->label1 = (gcnew System::Windows::Forms::Label());
  58.             this->label2 = (gcnew System::Windows::Forms::Label());
  59.             this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());
  60.             this->radioButton2 = (gcnew System::Windows::Forms::RadioButton());
  61.             this->radioButton3 = (gcnew System::Windows::Forms::RadioButton());
  62.             this->radioButton4 = (gcnew System::Windows::Forms::RadioButton());
  63.             this->button3 = (gcnew System::Windows::Forms::Button());
  64.             this->SuspendLayout();
  65.             //
  66.             // button1
  67.             //
  68.             this->button1->Location = System::Drawing::Point(424, 25);
  69.             this->button1->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  70.             this->button1->Name = L"button1";
  71.             this->button1->Size = System::Drawing::Size(112, 35);
  72.             this->button1->TabIndex = 0;
  73.             this->button1->Text = L"Poprzednie";
  74.             this->button1->UseVisualStyleBackColor = true;
  75.             this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
  76.             //
  77.             // button2
  78.             //
  79.             this->button2->Location = System::Drawing::Point(546, 22);
  80.             this->button2->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  81.             this->button2->Name = L"button2";
  82.             this->button2->Size = System::Drawing::Size(112, 35);
  83.             this->button2->TabIndex = 1;
  84.             this->button2->Text = L"Następne";
  85.             this->button2->UseVisualStyleBackColor = true;
  86.             this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
  87.             //
  88.             // label1
  89.             //
  90.             this->label1->AutoSize = true;
  91.             this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  92.                 static_cast<System::Byte>(238)));
  93.             this->label1->Location = System::Drawing::Point(20, 20);
  94.             this->label1->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
  95.             this->label1->Name = L"label1";
  96.             this->label1->Size = System::Drawing::Size(152, 33);
  97.             this->label1->TabIndex = 2;
  98.             this->label1->Text = L"Pytanie #1";
  99.             //
  100.             // label2
  101.             //
  102.             this->label2->AutoSize = true;
  103.             this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  104.                 static_cast<System::Byte>(238)));
  105.             this->label2->Location = System::Drawing::Point(20, 98);
  106.             this->label2->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
  107.             this->label2->Name = L"label2";
  108.             this->label2->Size = System::Drawing::Size(352, 33);
  109.             this->label2->TabIndex = 3;
  110.             this->label2->Text = L"Kliknij aby poznać pytanie";
  111.             this->label2->Click += gcnew System::EventHandler(this, &Form1::label2_Click);
  112.             //
  113.             // radioButton1
  114.             //
  115.             this->radioButton1->AutoSize = true;
  116.             this->radioButton1->Location = System::Drawing::Point(36, 174);
  117.             this->radioButton1->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  118.             this->radioButton1->Name = L"radioButton1";
  119.             this->radioButton1->Size = System::Drawing::Size(125, 24);
  120.             this->radioButton1->TabIndex = 4;
  121.             this->radioButton1->TabStop = true;
  122.             this->radioButton1->Text = L"odpowiedź A";
  123.             this->radioButton1->UseVisualStyleBackColor = true;
  124.             this->radioButton1->CheckedChanged += gcnew System::EventHandler(this, &Form1::radioButton1_CheckedChanged);
  125.             //
  126.             // radioButton2
  127.             //
  128.             this->radioButton2->AutoSize = true;
  129.             this->radioButton2->Location = System::Drawing::Point(36, 209);
  130.             this->radioButton2->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  131.             this->radioButton2->Name = L"radioButton2";
  132.             this->radioButton2->Size = System::Drawing::Size(125, 24);
  133.             this->radioButton2->TabIndex = 5;
  134.             this->radioButton2->TabStop = true;
  135.             this->radioButton2->Text = L"odpowiedź B";
  136.             this->radioButton2->UseVisualStyleBackColor = true;
  137.             //
  138.             // radioButton3
  139.             //
  140.             this->radioButton3->AutoSize = true;
  141.             this->radioButton3->Location = System::Drawing::Point(36, 245);
  142.             this->radioButton3->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  143.             this->radioButton3->Name = L"radioButton3";
  144.             this->radioButton3->Size = System::Drawing::Size(125, 24);
  145.             this->radioButton3->TabIndex = 6;
  146.             this->radioButton3->TabStop = true;
  147.             this->radioButton3->Text = L"odpowiedź C";
  148.             this->radioButton3->UseVisualStyleBackColor = true;
  149.             //
  150.             // radioButton4
  151.             //
  152.             this->radioButton4->AutoSize = true;
  153.             this->radioButton4->Location = System::Drawing::Point(34, 280);
  154.             this->radioButton4->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  155.             this->radioButton4->Name = L"radioButton4";
  156.             this->radioButton4->Size = System::Drawing::Size(126, 24);
  157.             this->radioButton4->TabIndex = 7;
  158.             this->radioButton4->TabStop = true;
  159.             this->radioButton4->Text = L"odpowiedź D";
  160.             this->radioButton4->UseVisualStyleBackColor = true;
  161.             //
  162.             // button3
  163.             //
  164.             this->button3->Location = System::Drawing::Point(36, 335);
  165.             this->button3->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  166.             this->button3->Name = L"button3";
  167.             this->button3->Size = System::Drawing::Size(112, 35);
  168.             this->button3->TabIndex = 8;
  169.             this->button3->Text = L"OK";
  170.             this->button3->UseVisualStyleBackColor = true;
  171.             this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
  172.             //
  173.             // Form1
  174.             //
  175.             this->AutoScaleDimensions = System::Drawing::SizeF(9, 20);
  176.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  177.             this->ClientSize = System::Drawing::Size(681, 512);
  178.             this->Controls->Add(this->button3);
  179.             this->Controls->Add(this->radioButton4);
  180.             this->Controls->Add(this->radioButton3);
  181.             this->Controls->Add(this->radioButton2);
  182.             this->Controls->Add(this->radioButton1);
  183.             this->Controls->Add(this->label2);
  184.             this->Controls->Add(this->label1);
  185.             this->Controls->Add(this->button2);
  186.             this->Controls->Add(this->button1);
  187.             this->Margin = System::Windows::Forms::Padding(4, 5, 4, 5);
  188.             this->Name = L"Form1";
  189.             this->Text = L"Quiz Matematyczny by Zuzanna Prościak";
  190.             this->ResumeLayout(false);
  191.             this->PerformLayout();
  192.  
  193.         }
  194. #pragma endregion
  195.     private: System::Void label2_Click(System::Object^ sender, System::EventArgs^ e) {
  196.         if (number == 1) {
  197.             label2->Text = "Jaki jest wynik działania 2 + 2 * 2";
  198.             radioButton1->Text = "4";
  199.             radioButton2->Text = "2";
  200.             radioButton3->Text = "6"; //poprawna odp
  201.             radioButton4->Text = "10";
  202.         }
  203.         if (number == 2) {
  204.             label2->Text = "Wynik działania 2 + 2 + 4 * 4 to";
  205.             radioButton1->Text = "20";//poprawna odp
  206.             radioButton2->Text = "32";
  207.             radioButton3->Text = "28";
  208.             radioButton4->Text = "36";
  209.         }
  210.         if (number == 3) {
  211.             label2->Text = "Ile wynosi pole kwadratu o boku 1,5cm?";
  212.             radioButton1->Text = "1,25cm^2";
  213.             radioButton2->Text = "1,75cm^2";
  214.             radioButton3->Text = "2,25cm^2";//poprawna odp
  215.             radioButton4->Text = "3,5cm^2";
  216.         }
  217.         if (number == 4) {
  218.             label2->Text = "Cegła waży 2kg i pół cegły. Ile waży cegła?";
  219.             radioButton1->Text = "4 kg";//poprawna odp
  220.             radioButton2->Text = "2 kg";
  221.             radioButton3->Text = "6 kg";
  222.             radioButton4->Text = "10 kg";
  223.         }
  224.         if (number == 5) {
  225.             label2->Text = "Jeśli x = 6 - 2x, ile wynosi x?";
  226.             radioButton1->Text = "3";
  227.             radioButton2->Text = "-6";
  228.             radioButton3->Text = "4";
  229.             radioButton4->Text = "2";//poprawna odp
  230.         }
  231.         if (number == 6) {
  232.             label2->Text = "Wynik działania 7 * 77 to: ";
  233.             radioButton1->Text = "495";
  234.             radioButton2->Text = "539";//poprawna odp
  235.             radioButton3->Text = "620";
  236.             radioButton4->Text = "449";
  237.         }
  238.         if (number == 7) {
  239.             label2->Text = "Wynik działania 19 + 5 * 2 - 16 + 3 * 1 to: ";
  240.             radioButton1->Text = "48";
  241.             radioButton2->Text = "16";//poprawna odp
  242.             radioButton3->Text = "35";
  243.             radioButton4->Text = "8";
  244.         }
  245.         if (number == 8) {
  246.             label2->Text = "Wynik wyrażenia 3 do sześcianu to: ";
  247.             radioButton1->Text = "27";//poprawna odp
  248.             radioButton2->Text = "9";
  249.             radioButton3->Text = "81";
  250.             radioButton4->Text = "5";
  251.         }
  252.         if (number == 9) {
  253.             label2->Text = "Wynik wyrażenia (-9)-(-23) to: ";
  254.             radioButton1->Text = "32";
  255.             radioButton2->Text = "14";//poprawna odp
  256.             radioButton3->Text = "-14";
  257.             radioButton4->Text = "-32";
  258.         }
  259.         if (number == 10) {
  260.             label2->Text = "Jeżeli a = -2, b = 2, c = 3,14 oblicz b * c - a";
  261.             radioButton1->Text = "8,28";//poprawna odp
  262.             radioButton2->Text = "6,14";
  263.             radioButton3->Text = "-4,14";
  264.             radioButton4->Text = "0";
  265.         }
  266.     }
  267. private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
  268.     if (number == 1) {
  269.         if (radioButton1->Checked) {
  270.             MessageBox::Show("Odpowiedź niepoprawna");
  271.         }
  272.         if (radioButton2->Checked) {
  273.             MessageBox::Show("Odpowiedź niepoprawna");
  274.         }
  275.         if (radioButton3->Checked) {
  276.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  277.             wynik += 1;
  278.         }
  279.         if (radioButton4->Checked) {
  280.             MessageBox::Show("Odpowiedź niepoprawna");
  281.         }
  282.     }
  283.     if (number == 2) {
  284.         if (radioButton1->Checked) {
  285.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  286.             wynik += 1;
  287.         }
  288.         if (radioButton2->Checked) {
  289.             MessageBox::Show("Odpowiedź niepoprawna");
  290.         }
  291.         if (radioButton3->Checked) {
  292.             MessageBox::Show("Odpowiedź niepoprawna");
  293.         }
  294.         if (radioButton4->Checked) {
  295.             MessageBox::Show("Odpowiedź niepoprawna");
  296.         }
  297.     }
  298.     if (number == 3) {
  299.         if (radioButton1->Checked) {
  300.             MessageBox::Show("Odpowiedź niepoprawna");
  301.         }
  302.         if (radioButton2->Checked) {
  303.             MessageBox::Show("Odpowiedź niepoprawna");
  304.         }
  305.         if (radioButton3->Checked) {
  306.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  307.             wynik += 1;
  308.         }
  309.         if (radioButton4->Checked) {
  310.             MessageBox::Show("Odpowiedź niepoprawna");
  311.         }
  312.     }
  313.     if (number == 4) {
  314.         if (radioButton1->Checked) {
  315.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  316.             wynik += 1;
  317.         }
  318.         if (radioButton2->Checked) {
  319.             MessageBox::Show("Odpowiedź niepoprawna");
  320.         }
  321.         if (radioButton3->Checked) {
  322.             MessageBox::Show("Odpowiedź niepoprawna");
  323.         }
  324.         if (radioButton4->Checked) {
  325.             MessageBox::Show("Odpowiedź niepoprawna");
  326.         }
  327.     }
  328.     if (number == 5) {
  329.         if (radioButton1->Checked) {
  330.             MessageBox::Show("Odpowiedź niepoprawna");
  331.         }
  332.         if (radioButton2->Checked) {
  333.             MessageBox::Show("Odpowiedź niepoprawna");
  334.         }
  335.         if (radioButton3->Checked) {
  336.             MessageBox::Show("Odpowiedź niepoprawna");
  337.         }
  338.         if (radioButton4->Checked) {
  339.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  340.             wynik += 1;
  341.         }
  342.     }
  343.     if (number == 6) {
  344.         if (radioButton1->Checked) {
  345.             MessageBox::Show("Odpowiedź niepoprawna");
  346.         }
  347.         if (radioButton2->Checked) {
  348.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  349.             wynik += 1;
  350.         }
  351.         if (radioButton3->Checked) {
  352.             MessageBox::Show("Odpowiedź niepoprawna");
  353.         }
  354.         if (radioButton4->Checked) {
  355.             MessageBox::Show("Odpowiedź niepoprawna");
  356.         }
  357.     }
  358.     if (number == 7) {
  359.         if (radioButton1->Checked) {
  360.             MessageBox::Show("Odpowiedź niepoprawna");
  361.         }
  362.         if (radioButton2->Checked) {
  363.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  364.             wynik += 1;
  365.         }
  366.         if (radioButton3->Checked) {
  367.             MessageBox::Show("Odpowiedź niepoprawna");
  368.         }
  369.         if (radioButton4->Checked) {
  370.             MessageBox::Show("Odpowiedź niepoprawna");
  371.         }
  372.     }
  373.     if (number == 8) {
  374.         if (radioButton1->Checked) {
  375.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  376.             wynik += 1;
  377.         }
  378.         if (radioButton2->Checked) {
  379.             MessageBox::Show("Odpowiedź niepoprawna");
  380.         }
  381.         if (radioButton3->Checked) {
  382.             MessageBox::Show("Odpowiedź niepoprawna");
  383.         }
  384.         if (radioButton4->Checked) {
  385.             MessageBox::Show("Odpowiedź niepoprawna");
  386.         }
  387.     }
  388.     if (number == 9) {
  389.         if (radioButton1->Checked) {
  390.             MessageBox::Show("Odpowiedź niepoprawna");
  391.         }
  392.         if (radioButton2->Checked) {
  393.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  394.             wynik += 1;
  395.         }
  396.         if (radioButton3->Checked) {
  397.             MessageBox::Show("Odpowiedź niepoprawna");
  398.         }
  399.         if (radioButton4->Checked) {
  400.             MessageBox::Show("Odpowiedź niepoprawna");
  401.         }
  402.     }
  403.     if (number == 10) {
  404.         if (radioButton1->Checked) {
  405.             MessageBox::Show("Odpowiedź poprawna + 1 pkt");
  406.             wynik += 1;
  407.         }
  408.         if (radioButton2->Checked) {
  409.             MessageBox::Show("Odpowiedź niepoprawna");
  410.         }
  411.         if (radioButton3->Checked) {
  412.             MessageBox::Show("Odpowiedź niepoprawna");
  413.         }
  414.         if (radioButton4->Checked) {
  415.             MessageBox::Show("Odpowiedź niepoprawna");
  416.         }
  417.         MessageBox::Show("Twój wynik quizu " + wynik + " na 10 możliwych", "Wynik");
  418.     }
  419. }
  420. private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
  421.     number++;
  422.     label1->Text = "Pytanie #" + number;
  423.     label2->Text = "Kliknij aby poznać pytanie";
  424.     radioButton1->Text = "odpowiedź A";
  425.     radioButton2->Text = "odpowiedź B";
  426.     radioButton3->Text = "odpowiedź C";
  427.     radioButton4->Text = "odpowiedź D";
  428.     radioButton1->Checked = false;
  429.     radioButton2->Checked = false;
  430.     radioButton3->Checked = false;
  431.     radioButton4->Checked = false;
  432.     if (number >= 10) {
  433.         MessageBox::Show("Dziesiąte pytanie jest ostatnie!");
  434.         number = 10;
  435.         label1->Text = "Pytanie #" + number;
  436.     }
  437. }
  438. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
  439.     number--;
  440.     label1->Text = "Pytanie #" + number;
  441.     label2->Text = "Kliknij aby poznać pytanie";
  442.     radioButton1->Text = "odpowiedź A";
  443.     radioButton2->Text = "odpowiedź B";
  444.     radioButton3->Text = "odpowiedź C";
  445.     radioButton4->Text = "odpowiedź D";
  446.     radioButton1->Checked = false;
  447.     radioButton2->Checked = false;
  448.     radioButton3->Checked = false;
  449.     radioButton4->Checked = false;
  450.     if (number <= 1) {
  451.         MessageBox::Show("Aktualnie cofnięto do pierwszego pytania!");
  452.         number = 1;
  453.         label1->Text = "Pytanie #" + number;
  454.     }
  455. }
  456. private: System::Void radioButton1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
  457.  
  458. }
  459. };
  460. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement