Sunday, December 10, 2017

Stacks




This in progress blog




Stack linked list implementation



Stack array implementation


 package com.tvidushi.stack;  
 import org.junit.Test;  
 import com.tvidushi.stack.exception.StackOverFlowException;  
 import com.tvidushi.stack.exception.StackUnderFlowException;  
 import com.tvidushi.stack.stack.StackLlistImpl;  
 import com.tvidushi.stack.stack.StackLlistImpl.Node;  
 import junit.framework.TestCase;  
 /**  
  * @author takshila.vidushi  
  *  
  */  
 public class TestStackLlistImpl extends TestCase {  
      StackLlistImpl stack = new StackLlistImpl(new Node(90,null));  
        public void setup() {  
        }       
        @Test  
        public void testPush() throws StackOverFlowException {       
                  stack.push(45);  
                  stack.push(89);;  
        }  
        @Test  
        public void testPeek() throws StackUnderFlowException {       
                  stack.peek();  
        }  
        @Test  
        public void testPop() throws StackUnderFlowException {       
                  stack.pop();  
        }  
        @Test(expected =StackUnderFlowException.class)  
        public void testPop1() throws StackUnderFlowException {       
                  stack.pop();  
        }  

Download here

No comments:

Post a Comment