#include <iostream.h>
#include <stdlib.h>
#include"JobEntry.h"

// constructor
Job::Job()
{
  int Null=0;
  headNode = new Node();
  headNode->setNext(NULL);
  currentNode=NULL;
  lastCurrentNode=NULL;
  size=0;
  

}

// add() class methd
void Job::add(int addobject)
{
 Node* newNode = new Node();
 newNode->set(addobject);

 if(currentNode!= NULL)
     {
       newNode->setNext(currentNode->getNext());
       currentNode->setNext(newNode);
       lastCurrentNode = currentNode;
       currentNode=newNode;
      }
 else
     {
       newNode->setNext(NULL);
       headNode->setNext(newNode);
       lastCurrentNode = headNode;
       currentNode = newNode;
     }
    size++;
 }
 
 
 
 
 
 
 
 
 
 
 
 void Job::add1(char addobj)
{
 Node* newNode = new Node();
 newNode->set1(addobj);

 if(currentNode!= NULL)
     {
       newNode->setNext(currentNode->getNext());
       currentNode->setNext(newNode);
       lastCurrentNode = currentNode;
       currentNode=newNode;
      }
 else
     {
       newNode->setNext(NULL);
       headNode->setNext(newNode);
       lastCurrentNode = headNode;
       currentNode = newNode;
     }
    size++;
 }
 
 
 
 void Job::add2(char addobj2)
{
 Node* newNode = new Node();
 newNode->set1(addobj2);

 if(currentNode!= NULL)
     {
       newNode->setNext(currentNode->getNext());
       currentNode->setNext(newNode);
       lastCurrentNode = currentNode;
       currentNode=newNode;
      }
 else
     {
       newNode->setNext(NULL);
       headNode->setNext(newNode);
       lastCurrentNode = headNode;
       currentNode = newNode;
     }
    size++;
 }
 
 
 
 
void Job::print(Job job)
{
    Node* savedCurrentNode  =  job.currentNode;
   job.currentNode  =  job.headNode;
    
    for(int i = 1; job.next(); i++)
    {

         cout << " \nPriority " << job.get()<<endl;
    }
        job.currentNode  =  savedCurrentNode;

}
 
 
  
 


 // get() class method
 int Job::get()
 {
  if(currentNode!=NULL)
  return currentNode->get();
 }
 
  char Job::get1()
 {
  if(currentNode!=NULL)
  return currentNode->get1();
 }

 Node* Job::getHead()
 {
  return headNode;
 }
 // next() class method
 bool Job::next()
{
  if(currentNode==NULL) return false;
  lastCurrentNode=currentNode;
  currentNode = currentNode->getNext();

  if(currentNode==NULL || size==0)
  return false;
  else
  return true;
}




