示例#1
0
文件: Program.cs 项目: motakjan/PJ2
        public static void Main(string[] args)
        {
            IZasobnik <int?> stack = new MujZasobnik <int?>(5);                 //Nullable<int> = int? - int kde muze byt i null

            stack.Push(1);
            stack.Push(2);
            stack.Push(null);
            stack.Push(4);
            Console.WriteLine(stack.Top());
            Console.WriteLine(stack.Pop());
            Console.WriteLine(stack.Pop());
            Console.WriteLine(stack.Pop());
            Console.WriteLine(stack.Pop());

            Console.WriteLine("Fronta");

            IFronta <string> fronta = new MojeFronta <string>(5);

            fronta.Add("1");
            Console.WriteLine(fronta.Get());
            fronta.Add("2");
            fronta.Add("3");
            fronta.Add("4");
            fronta.Add("5");
            Console.WriteLine(fronta.Get());
        }
示例#2
0
        static void Main(string[] args)
        {
            MujZasobnik z = new MujZasobnik(5);

            try {
                z.Pop();
            }
            catch (StackIsEmptyException e) {
                Console.WriteLine("Zachzceno");
                throw;
            }
            catch (Exception e) {
                Console.WriteLine("Obecna");
            }

            z.Push(5);
            z.Push(10);
            Console.WriteLine(z.Top);
        }