#include <cstring>
using namespace std;
struct Persons
{
string firstName;
string secondName;
string CNP;
string Email;
};
class NODE
{
private:
NODE *next;
public:
Persons *box = new Persons();
NODE(string firstName, string secondName, string CNP, string Email)
{
box->firstName = firstName;
box->secondName = secondName;
box->CNP = CNP;
box->Email = Email;
}
void SetNext(NODE *next)
{
this->next = next;
}
NODE* GetNext()
{
return next;
}
};
class QueueSinglyLinkedList
{
private:
NODE *front;
NODE *rear;
public:
QueueSinglyLinkedList()
{
front = NULL;
rear = NULL;
}
bool isEmpty()
{
return front == NULL;
}
void InsertNODE(NODE *newNode)
{
if (isEmpty())
front = rear = newNode;
else
rear->SetNext(newNode);
rear = newNode;
rear->SetNext(NULL);
}
void DeleteNODE()
{
if (isEmpty())
cout << "\n Queue is Empty." << endl;
else
{
NODE *temp = front;
front = front->GetNext();
delete temp;
}
}
void Print()
{
if (isEmpty())
cout << "\n Queue is Empty.";
else
{
NODE *temp = front;
while (temp->GetNext() != NULL)
{
cout << "\n First Name : " << temp->box->firstName;
cout << "\n Second Name : " << temp->box->secondName;
cout << "\n CNP : " << temp->box->CNP;
cout << "\n Email : " << temp->box->Email;
temp = temp->GetNext();
cout << endl;
}
cout << "\n First Name : " << temp->box->firstName;
cout << "\n Second Name : " << temp->box->secondName;
cout << "\n CNP : " << temp->box->CNP;
cout << "\n Email : " << temp->box->Email;
}
cout << endl;
}
};
int main()
{
QueueSinglyLinkedList *ptr = new QueueSinglyLinkedList();
ptr->InsertNODE(&obj1);
ptr->InsertNODE(&obj2);
ptr->InsertNODE(&obj3);
ptr->InsertNODE(&obj4);
ptr->InsertNODE(&obj5);
ptr->Print();
ptr->DeleteNODE();
ptr->DeleteNODE();
ptr->DeleteNODE();
ptr->DeleteNODE();
ptr->DeleteNODE();
ptr->DeleteNODE();
ptr->Print();
return 0;
}