All pastes #341688 Raw Edit

Mine

public text v1 · immutable
·published 2007-02-05 20:17 UTC
rendered paste body
public class wineList
{
	private wineNode head;
	private wineNode q;
	
	public wineList()
	{
		this.head = null;
		this.q = null;
	}
	public wineList(wineNode element)
	{
		this.head = element;
		this.q = element;
		q.setNext(null);
	}
	private boolean isEmpty()
	{
		if(q == null && head == null)
			return true;
		else return false;
	}
	public void push(wineNode element)
	{
		if(isEmpty())
		{
			this.q = element;
			q.setNext(null);
			this.head = element;	
		}
		else
		{
			this.q = element;
			q.setNext(head);
			this.head = element;
		}		
	}
	public void pop()
	{
		this.q = head;
		this.head = q.getNext();
		q.setNext(null);
	}
	public void printList()
	{
		while(q.getNext() != null)
		{
			this.q = this.head;
			System.out.println(q.toString());
			this.q = q.getNext();	
		}		
	}	
}