#include "LList.h"

 LList::LList(void)
 {

	pHead = new(node);  //create a dummy head node
	pHead->next = NULL; 
	pCurrent=pHead;


 }
 void LList::add(TYPE data)
 {
	 //adds a node after the current node
	node* x = new(node);      //reserve space for new node and get its address
	x->item = data;     // put data in the new node
	x->next = pCurrent->next; //get new node to point to the node after current node
    pCurrent->next = x;       // get current node to point to new node
 }

 void LList::del(void)
	 //deletes node following cyurrent node (if it exists)
 {
 	node *ptemp;
	ptemp=pCurrent->next;
	if (pCurrent->next !=NULL)   //can't delete anything after the end of the list!
	{
		pCurrent->next=pCurrent->next->next;  //current node's next pointer
								//leap frogs node after the current node
			  					// and therefore points to next but one node
        delete(ptemp);        //free memory associated with leap-frogged node
	}

 }

 bool LList::isEmpty(void)
 {
if (pHead->next==NULL)   //no data exists so return true
	{
		return true;
	}
	else
		return false;
 }

bool LList::atEnd(void)
{
if (pCurrent->next==NULL)   //no data exists after end of list so return true
	{
		return true;
	}
	else
		return false;

}

 int LList::peek(void)
	 //peeks at the next node's contents
 {
	if (pCurrent->next!=NULL)   //no data exists after end of list so return -1
	{
		return pCurrent->next->item;
	}
	else
		return -1;
 }
 
