public class DynamicStack
{
	//you should have at least one attribute here...
	//it starts with the letter N and rhymes with ... "abode"
	Node top = null;
	
	//default constructor
	public DynamicStack()
	{
	}
	
	//prints out all the numbers in the stack
	public void print()
	{
		for (Node current = top; current != null; current = current.next)
			System.out.println(current.num);
	}
	
	//pushes one number onto the stack
	public void push(int num)
	{
		Node newNode = new Node();
		newNode.num = num;
		newNode.next = top;
		top = newNode;
	}
	
	//pops the top number off the stack
	public int pop()
	{
		if (!isEmpty())
		{
			Node oldTop = top;
			top = top.next;
			return oldTop.num;
		}
		return -999;
	}
	
	//returns the value of the top
	public int top()
	{
		return (top != null) ? top.num : -999;
	}
	
	//returns true if the stack is empty, and false otherwise
	public boolean isEmpty()
	{
		return top == null;
	}
}
