Advertisement
peterzig

[C++] Zadanie 7 dla Zuzi

May 10th, 2020
1,114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.76 KB | None | 0 0
  1. #pragma once
  2.  
  3. namespace CppCLRWinformsProjekt {
  4.  
  5.     using namespace System;
  6.     using namespace System::ComponentModel;
  7.     using namespace System::Collections;
  8.     using namespace System::Windows::Forms;
  9.     using namespace System::Data;
  10.     using namespace System::Drawing;
  11.  
  12.     static int price = 70000;
  13.     static double base = 0;
  14.     double value = 0;
  15.  
  16.     public ref class Form1 : public System::Windows::Forms::Form
  17.     {
  18.     public:
  19.         Form1(void)
  20.         {
  21.             InitializeComponent();
  22.  
  23.         }
  24.  
  25.     protected:
  26.  
  27.         ~Form1()
  28.         {
  29.             if (components)
  30.             {
  31.                 delete components;
  32.             }
  33.         }
  34.     private: System::Windows::Forms::ComboBox^ comboBox1;
  35.     protected:
  36.     private: System::Windows::Forms::Label^ label1;
  37.     private: System::Windows::Forms::TextBox^ textBox1;
  38.     private: System::Windows::Forms::Label^ label2;
  39.     private: System::Windows::Forms::CheckBox^ checkBox1;
  40.     private: System::Windows::Forms::CheckBox^ checkBox2;
  41.     private: System::Windows::Forms::CheckBox^ checkBox3;
  42.     private: System::Windows::Forms::Label^ label3;
  43.     private: System::Windows::Forms::Label^ label4;
  44.  
  45.     private:
  46.  
  47.         System::ComponentModel::Container ^components;
  48.  
  49. #pragma region Windows Form Designer generated code
  50.  
  51.         void InitializeComponent(void)
  52.         {
  53.             this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
  54.             this->label1 = (gcnew System::Windows::Forms::Label());
  55.             this->textBox1 = (gcnew System::Windows::Forms::TextBox());
  56.             this->label2 = (gcnew System::Windows::Forms::Label());
  57.             this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
  58.             this->checkBox2 = (gcnew System::Windows::Forms::CheckBox());
  59.             this->checkBox3 = (gcnew System::Windows::Forms::CheckBox());
  60.             this->label3 = (gcnew System::Windows::Forms::Label());
  61.             this->label4 = (gcnew System::Windows::Forms::Label());
  62.             this->SuspendLayout();
  63.             //
  64.             // comboBox1
  65.             //
  66.             this->comboBox1->FormattingEnabled = true;
  67.             this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^  >(3) { L"10", L"15", L"20" });
  68.             this->comboBox1->Location = System::Drawing::Point(39, 89);
  69.             this->comboBox1->Name = L"comboBox1";
  70.             this->comboBox1->Size = System::Drawing::Size(162, 28);
  71.             this->comboBox1->TabIndex = 0;
  72.             this->comboBox1->Text = L"Ustaw procent";
  73.             this->comboBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBox1_SelectedIndexChanged);
  74.             //
  75.             // label1
  76.             //
  77.             this->label1->AutoSize = true;
  78.             this->label1->Location = System::Drawing::Point(35, 9);
  79.             this->label1->Name = L"label1";
  80.             this->label1->Size = System::Drawing::Size(80, 20);
  81.             this->label1->TabIndex = 1;
  82.             this->label1->Text = L"Zadanie 6";
  83.             //
  84.             // textBox1
  85.             //
  86.             this->textBox1->Location = System::Drawing::Point(39, 46);
  87.             this->textBox1->MaxLength = 10;
  88.             this->textBox1->Name = L"textBox1";
  89.             this->textBox1->Size = System::Drawing::Size(100, 26);
  90.             this->textBox1->TabIndex = 2;
  91.             this->textBox1->TextChanged += gcnew System::EventHandler(this, &Form1::textBox1_TextChanged);
  92.             //
  93.             // label2
  94.             //
  95.             this->label2->AutoSize = true;
  96.             this->label2->Location = System::Drawing::Point(473, 13);
  97.             this->label2->Name = L"label2";
  98.             this->label2->Size = System::Drawing::Size(80, 20);
  99.             this->label2->TabIndex = 3;
  100.             this->label2->Text = L"Zadanie 8";
  101.             //
  102.             // checkBox1
  103.             //
  104.             this->checkBox1->AutoSize = true;
  105.             this->checkBox1->Location = System::Drawing::Point(477, 74);
  106.             this->checkBox1->Name = L"checkBox1";
  107.             this->checkBox1->Size = System::Drawing::Size(154, 24);
  108.             this->checkBox1->TabIndex = 4;
  109.             this->checkBox1->Text = L"felgi 17\" (2000zł)";
  110.             this->checkBox1->UseVisualStyleBackColor = true;
  111.             this->checkBox1->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox1_CheckedChanged);
  112.             //
  113.             // checkBox2
  114.             //
  115.             this->checkBox2->AutoSize = true;
  116.             this->checkBox2->Location = System::Drawing::Point(477, 114);
  117.             this->checkBox2->Name = L"checkBox2";
  118.             this->checkBox2->Size = System::Drawing::Size(231, 24);
  119.             this->checkBox2->TabIndex = 5;
  120.             this->checkBox2->Text = L"tapicerka skórzana (5000zł)";
  121.             this->checkBox2->UseVisualStyleBackColor = true;
  122.             this->checkBox2->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox2_CheckedChanged);
  123.             //
  124.             // checkBox3
  125.             //
  126.             this->checkBox3->AutoSize = true;
  127.             this->checkBox3->Location = System::Drawing::Point(477, 156);
  128.             this->checkBox3->Name = L"checkBox3";
  129.             this->checkBox3->Size = System::Drawing::Size(227, 24);
  130.             this->checkBox3->TabIndex = 6;
  131.             this->checkBox3->Text = L"reflektory LEDowe (2300zł)";
  132.             this->checkBox3->UseVisualStyleBackColor = true;
  133.             this->checkBox3->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox3_CheckedChanged);
  134.             //
  135.             // label3
  136.             //
  137.             this->label3->AutoSize = true;
  138.             this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  139.                 static_cast<System::Byte>(238)));
  140.             this->label3->Location = System::Drawing::Point(470, 207);
  141.             this->label3->Name = L"label3";
  142.             this->label3->Size = System::Drawing::Size(310, 32);
  143.             this->label3->TabIndex = 7;
  144.             this->label3->Text = L"Cena auta : 70000 PLN";
  145.             //
  146.             // label4
  147.             //
  148.             this->label4->AutoSize = true;
  149.             this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  150.                 static_cast<System::Byte>(238)));
  151.             this->label4->Location = System::Drawing::Point(33, 135);
  152.             this->label4->Name = L"label4";
  153.             this->label4->Size = System::Drawing::Size(207, 32);
  154.             this->label4->TabIndex = 8;
  155.             this->label4->Text = L"Procent liczby :";
  156.             //
  157.             // Form1
  158.             //
  159.             this->AutoScaleDimensions = System::Drawing::SizeF(9, 20);
  160.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  161.             this->ClientSize = System::Drawing::Size(892, 475);
  162.             this->Controls->Add(this->label4);
  163.             this->Controls->Add(this->label3);
  164.             this->Controls->Add(this->checkBox3);
  165.             this->Controls->Add(this->checkBox2);
  166.             this->Controls->Add(this->checkBox1);
  167.             this->Controls->Add(this->label2);
  168.             this->Controls->Add(this->textBox1);
  169.             this->Controls->Add(this->label1);
  170.             this->Controls->Add(this->comboBox1);
  171.             this->Name = L"Form1";
  172.             this->Text = L"Made by Zuzanna Prościak, 10/05/2020";
  173.             this->ResumeLayout(false);
  174.             this->PerformLayout();
  175.  
  176.         }
  177. #pragma endregion
  178.     private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
  179.         if (checkBox1->Checked) {
  180.             price += 2000;
  181.             label3->Text = "Cena auta : " + price + " PLN";
  182.         }
  183.         else {
  184.             price -= 2000;
  185.             label3->Text = "Cena auta : " + price + " PLN";
  186.         }
  187.     }
  188. private: System::Void checkBox2_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
  189.     if (checkBox2->Checked) {
  190.         price += 5000;
  191.         label3->Text = "Cena auta : " + price + " PLN";
  192.     }
  193.     else {
  194.         price -= 5000;
  195.         label3->Text = "Cena auta : " + price + " PLN";
  196.     }
  197. }
  198. private: System::Void checkBox3_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
  199.     if (checkBox3->Checked) {
  200.         price += 2300;
  201.         label3->Text = "Cena auta : " + price + " PLN";
  202.     }
  203.     else {
  204.         price -= 2300;
  205.         label3->Text = "Cena auta : " + price +" PLN";
  206.     }
  207. }
  208. private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
  209.     if(textBox1->Text != ""){
  210.         value = Convert::ToDouble(textBox1->Text); 
  211.     }
  212.     else {
  213.         label4->Text = comboBox1->Text + " procent liczby: 0 to 0";
  214.     }
  215.  
  216. }
  217. private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
  218.     int index = comboBox1->SelectedIndex;
  219.     double d = Convert::ToDouble(comboBox1->Items[index]);
  220.     label4->Text = comboBox1->Text + " procent liczby: " + value + " to " + (d/100) * value;   
  221. }
  222. };
  223.  
  224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement