using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Lista_Jednokierunkowa { public partial class Form1 : Form { Kolejka kolejka = new Kolejka(); Stos stos = new Stos(); public Form1() { InitializeComponent(); checkedListBox1.SetItemChecked(0, true); } int a; private void button1_Click(object sender, EventArgs e) { int x = 0; Int32.TryParse(textBox1.Text, out x); if (a == 0) { kolejka.Push(x); } if(a == 1) { stos.Push(x); } } private void button2_Click(object sender, EventArgs e) { if (a == 0) { kolejka.Pop(); } if (a == 1) { stos.Pop(); } } private void button3_Click(object sender, EventArgs e) { if (a == 0) { string str = kolejka.Length().ToString(); label1.Text = str; } if (a == 1) { string str = stos.Length().ToString(); label1.Text = str; } } private void button4_Click(object sender, EventArgs e) { if (a == 0) { string str = kolejka.Show(); label2.Text = str; } if (a == 1) { string str = stos.Show(); label2.Text = str; } } private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e) { int iSelectedIndex = checkedListBox1.SelectedIndex; if (iSelectedIndex == -1) return; for (int iIndex = 0; iIndex < checkedListBox1.Items.Count; iIndex++) checkedListBox1.SetItemCheckState(iIndex, CheckState.Unchecked); checkedListBox1.SetItemCheckState(iSelectedIndex, CheckState.Checked); if (checkedListBox1.GetItemChecked(0) == true) { a = 0; } if (checkedListBox1.GetItemChecked(1) == true) { a = 1; } } } }