//
//	Linked list bases Stack
//

public class Stack
{
	private ListNode top;
	private int length;
	public Stack()
	{
		length = 0;
		top = null;
	}
	public boolean isEmpty()
	{	return top == null;	}
	public int getLength()
	{	return length;	}
	public void push(String item)
	{
		ListNode temp = new ListNode(item, null);
		if(isEmpty())
		{
			top = temp;
			length ++;
		}
		else
		{
			temp.setLink(top);
			top = temp;
			length ++;
		}
		System.out.println("\n" + item + " was pushed in.");
	}
	public String pop()	// assume not empty
	{	String str = " ";
		length --;
		str = top.getData();
		top = top.getLink();
		System.out.println("\n" + str + " was poped out.");
		return str;
	}
	public void Print()
	{
		ListNode temp = top;

		System.out.println("\n\nThe Stack Top -> Bottom is:");
		while(temp != null)
		{
			System.out.println(temp.getData());
			temp = temp.getLink();
		}
	}
	public void makeEmpty()
	{
		top = null;
	}
}