#include "header.h" //constructor Queue::Queue() { } //destructor Queue::~Queue() { } //adds new node to stack void Queue::push(std::string name) { //new is the C++ version of new Node *newNode = new Node; //init values newNode->name = name; //assigns the current stack to "next" //making newNode on top of stack newNode->next = value; //value is assigned to newNode value = newNode; } std::string Queue::pop() { //return value std::string tstring; //stack is not null if (value) { Node *prevNode = value; Node *currNode = value->next; while (currNode->next) { prevNode = prevNode->next; currNode = currNode->next; } //assign top of stack to popped Node *popped = currNode; //return value tstring = popped->name; prevNode->next = NULL; //deletes popped, deallocating the memory. delete popped; } //stack is empty else { std::cout << "Queue is Empty" << std::endl; tstring = "Empty"; } return tstring; } //this returns string name of the top value void Queue::peek() { Node *list = value; while (list->next) { list = list->next; } std::cout << list->name << std::endl; } //prints all values of stack, starting at the top void Queue::printStack() { //temp node is assigned to our stack Node *list = value; //traverses through list and prints value while (list) { std::cout << list->name << "--> "; list = list->next; } std::cout << "End of Queue" << std::endl; } //checks if stack is empty bool Queue::isEmpty() { if (value) return false; else return true; }