示例#1
0
        public void Clear_ClearStackWithSomeElementsShouldWork()
        {
            // Arrange
            StackArray <int> sut = new StackArray <int>();
            int expected         = 0;

            // Act
            sut.Add(42);
            sut.Add(17);
            sut.Add(int.MaxValue);
            sut.Clear();
            int actual = sut.Size();

            // Assert
            Assert.Equal(expected, actual);
        }
示例#2
0
 public void CleanUp()
 {
     stackList.Clear();
     stackArray.Clear();
 }
示例#3
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Stacks.StackList <int> stack = new StackList <int>();
            stack.Push(12);
            stack.Push(13);
            stack.Push(14);

            Console.WriteLine(stack + Environment.NewLine);

            Console.WriteLine(stack.Top);
            stack.Pop();
            if (!stack.Pop())
            {
                Console.WriteLine("Prazna je lista bila");
            }

            Stacks.StackArray <int> stackArray = new StackArray <int>(2);

            stackArray.Push(12);
            stackArray.Push(13);
            stackArray.Push(14);             //StackArray<T> nece automatski promeniti velicinu

            Console.WriteLine(stackArray + Environment.NewLine);

            Console.WriteLine(stackArray.Top);

            Console.WriteLine("#Swap top");
            SwapTop(stackArray);
            Console.WriteLine(stackArray);

            stack.Push(14);
            stack.Push(15);
            stack.Push(16);

            Console.Write("#ispisi obrnuto ");
            IspisiStekObrnuto(stack);
            Console.WriteLine("#normalan ispis " + stack);

            stackArray.Clear();

            stack.Clear();

            stack.Push(1);
            stack.Push(2);
            stack.Push(3);
            stack.Push(4);
            stack.Push(5);
            stack.Push(6);

            Rotate(stack, 3);
            Console.WriteLine(stack);

            try {
                Console.WriteLine(stackArray.Top);
            }
            catch (Exception) {
                Console.WriteLine("List was empty");
            }

            Console.WriteLine(ProveriMatematickiIzrazIliStaVec("(3*(3+3))"));

            Console.WriteLine(ProveriMatematickiIzrazIliStaVec("(3+(4*3))"));
        }