Example #1
0
        public override int Pop()
        {
            while (!IsEmpty())
            {
                stackImpl.Push(base.Pop());
            }
            int ret = stackImpl.Pop();

            while (!stackImpl.IsEmpty())
            {
                Push(stackImpl.Pop());
            }
            return(ret);
        }
Example #2
0
        public void Pop()
        {
            StackImplementation <int> stack = new StackImplementation <int>(3);

            stack.Push(1);
            stack.Push(2);
            stack.Push(3);
            int val = stack.Pop();

            Assert.AreEqual(3, val);
            Assert.AreEqual(2, stack.Size);
        }
Example #3
0
        public void Run()
        {
            StackImplementation <int> si = new StackImplementation <int>();

            si.Push(1);
            si.Push(2);
            si.Push(3);
            si.Push(4);
            Console.WriteLine("Size of the stack: {0}", si.Count);
            Console.WriteLine("Removing the top item from the stack: {0}", si.Pop());
            Console.WriteLine("Size of the stack: {0}", si.Count);
            Console.WriteLine("Value of the top item from the stack: {0}", si.Peek());
        }
 public virtual int Pop()
 {
     return(impl.Pop());
 }
Example #5
0
        public void Exception_On_Too_Much_Pop()
        {
            StackImplementation <int> stack = new StackImplementation <int>(3);

            Assert.Throws <ExpenditureProhibitedException>(() => stack.Pop());
        }