#include "HW4-Todo-QueueLinkedList.hpp"
#include <iostream>

using namespace std;

TodoQueueLinkedList::TodoQueueLinkedList(){
    queueFront = NULL;
    queueEnd = NULL;
}

bool TodoQueueLinkedList::isEmpty(){
    if(queueFront == NULL && queueEnd == NULL){
        return true;
    }
    else{
        return false;
    }
}

void TodoQueueLinkedList::enqueue(string todoItem){
    TodoItem *temp = new TodoItem;
    temp->todo = todoItem;
    temp->next = NULL;
    if(isEmpty()){
        queueFront = queueEnd = temp;
    }
    else{
        queueEnd->next = temp;
        queueEnd = temp;
    }
}

void TodoQueueLinkedList::dequeue(){
    TodoItem *temp = queueFront;
    if(isEmpty()){
        cout << "Queue empty, cannot dequeue an item." << endl;
    }
    if(queueFront == queueEnd){
        queueFront = queueEnd = NULL;
    }
    else{
        queueFront = queueFront->next;
    }
    delete temp;
}

TodoItem* TodoQueueLinkedList::peek(){
    if(isEmpty()){
        cout << "Queue empty, cannot peek." << endl;
    }
    else{
        cout << queueFront->todo << endl;
    }
    return queueFront;
}
