Facebook
From Walloping Ostrich, 5 Years ago, written in C#.
Embed
Download Paste or View Raw
Hits: 239
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace Lista_Jednokierunkowa
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         Kolejka kolejka = new Kolejka();
  16.         Stos stos = new Stos();
  17.  
  18.         public Form1()
  19.         {
  20.             InitializeComponent();
  21.             checkedListBox1.SetItemChecked(0, true);
  22.         }
  23.        
  24.         int a;
  25.  
  26.         private void button1_Click(object sender, EventArgs e)
  27.         {
  28.             int x = 0;
  29.            
  30.             Int32.TryParse(textBox1.Text, out x);
  31.             if (a == 0)
  32.             {
  33.                 kolejka.Push(x);
  34.             }
  35.             if(a == 1)
  36.             {
  37.                 stos.Push(x);
  38.             }
  39.         }
  40.  
  41.         private void button2_Click(object sender, EventArgs e)
  42.         {
  43.             if (a == 0)
  44.             {
  45.                 kolejka.Pop();
  46.             }
  47.             if (a == 1)
  48.             {
  49.                 stos.Pop();
  50.             }
  51.         }
  52.  
  53.         private void button3_Click(object sender, EventArgs e)
  54.         {
  55.             if (a == 0)
  56.             {
  57.                 string str = kolejka.Length().ToString();
  58.                 label1.Text = str;
  59.             }
  60.             if (a == 1)
  61.             {
  62.                 string str = stos.Length().ToString();
  63.                 label1.Text = str;
  64.             }            
  65.         }
  66.  
  67.         private void button4_Click(object sender, EventArgs e)
  68.         {
  69.             if (a == 0)
  70.             {
  71.                 string str = kolejka.Show();
  72.                 label2.Text = str;
  73.             }
  74.             if (a == 1)
  75.             {
  76.                 string str = stos.Show();
  77.                 label2.Text = str;
  78.             }            
  79.         }
  80.  
  81.         private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
  82.         {
  83.             int iSelectedIndex = checkedListBox1.SelectedIndex;
  84.             if (iSelectedIndex == -1)
  85.                 return;
  86.             for (int iIndex = 0; iIndex < checkedListBox1.Items.Count; iIndex++)
  87.                 checkedListBox1.SetItemCheckState(iIndex, CheckState.Unchecked);
  88.             checkedListBox1.SetItemCheckState(iSelectedIndex, CheckState.Checked);
  89.            
  90.  
  91.             if (checkedListBox1.GetItemChecked(0) == true)
  92.             {
  93.                 a = 0;
  94.             }
  95.             if (checkedListBox1.GetItemChecked(1) == true)
  96.             {
  97.                 a = 1;
  98.             }
  99.         }
  100.     }
  101. }
  102.