Ticket Management System using link list

Ticket Management System using link list

 

#include<iostream>

#include<string>

#include<cstring>

#include<ctype.h>

using namespace std;

class Ticket

{

public:

	int ticketNo, seatNo, AirNo;

	string cnic, ticketDate; string FName;

	Ticket *next;

	Ticket()

	{

			FName= '\0';

		cnic = ticketDate = " ";

		ticketNo = seatNo = AirNo = 0;

	}

};

Ticket *head = NULL; int position=0;

class Airline{

public:

	void ResTicket()

	{

		system("cls");

		Ticket *Node = new Ticket;

		cout << "Enter the ticket number(integer):"; cin >> Node->ticketNo;

		cout << "Enter the Airline number(integer):"; cin >> Node->AirNo;

		cout << "Enter the seat number(integer):"; cin >> Node->seatNo; cin.ignore();

		cout << "Enter the Name:"; getline(cin, Node->FName);

		cout << "Enter the CNIC:"; getline(cin, Node->cnic);

		cout << "Enter the Flight Date and time:"; getline(cin, Node->ticketDate);

		if (head == NULL)

		{

			Node->next = NULL;

			head = Node;

		}

		else

		{

			Node->next = head;

			head = Node;

		}

	}

	void ResCancel()

	{

		system("cls");

		Ticket *temp = new Ticket;

		temp = head;

		int a, count = 0;

		cout << "Enter the ticket number to cancel the REservation(integer):"; cin >> a; cin.ignore();

		while (temp != NULL){

			if (a == temp->ticketNo)

			{

				temp->AirNo = 0;

				temp->cnic = " ";

				temp->FName= '\0';

				temp->seatNo = 0;

				temp->ticketDate = " ";

				count++;

				cout << temp->ticketNo << " is successfully cancel" << endl;

				cin.get();

			}

			temp = temp->next;

		}

		if (count == 0)

		{

			cout << endl << endl;

			cout << "Ticket number is not found" << endl;

			cin.get();

		}

	}

	void IsResCheck()

	{

		system("cls");

		Ticket *temp = new Ticket;

		temp = head;

		int a, count = 0;

		cout << "Enter the ticket number to check that is ticket is booked:"; cin >> a; cin.ignore();

		while (temp != head)

		{

			if (a == temp->ticketNo)

			{

				

				cout << "Your Name is:" << temp->FName<< endl;

				cout << "Your Ticket number is:" << temp->ticketNo << endl;

				cout << "Your seat number is:" << temp->seatNo << endl;

				cout << "Your Airline number is:" << temp->AirNo << endl;

				cout << "Your CNIC is:" << temp->cnic << endl;

				cout << "Your Flight Date and time is:" << temp->ticketDate << endl;

				count++;

				cout << endl << endl << "Reservation successfully checked" << endl;

				cin.get();

			}

			temp = temp->next;

		}

		if (count== 0)

		{

			cout << endl << endl;

			cout << "This Ticket Ticket Number is not Reserve" << endl;

			cin.get();

		}

	}



	void sortFullData()

	{

		Ticket *current = new Ticket;

		Ticket *pre = new Ticket;

		Ticket *temp1 = new Ticket;

		Ticket *agla = new Ticket;

		Ticket *preTemp = new Ticket;

		Ticket *temp, *ntemp, *ntemp1, *ntemp2; string a, b;

		current = head; temp1 = head;

		agla = current->next; 

		int j = 0;

		if (current == NULL){

			cout << "There is no data" << endl;

			cout << "Link list is empty" << endl;

		}

		

			else{

				while (agla!= NULL)

				{

					

					while (current!= NULL){

						if (toupper(current->FName > agla->FName))

						{

							swap(current->AirNo, agla->AirNo);

							swap(current->cnic, agla->cnic);

							swap(current->FName, agla->FName);

							swap(current->seatNo, agla->seatNo);

							swap(current->ticketDate, agla->ticketDate);

							swap(current->ticketNo, agla->ticketNo);

		

							

						}

						pre = current;

						current = current->next;

					}

					current = head;

					agla = agla->next;

					

				}

			}

	}



	void swapAlpha()

	{

		Ticket *current = new Ticket;

		Ticket *pre = new Ticket;

		Ticket *temp = new Ticket; string a, b;

		Ticket *agla = new Ticket;

		current = head;

		agla = current->next; int j = 0; temp = head;

			while (agla!= NULL)

			{

					while (current != NULL){

						if (toupper(current->FName > agla->FName))



						{

							a = current->FName;

							current->FName = agla->FName;

							agla->FName = a;

						}

						current = current->next;

					}

					current = head;

				agla = agla->next;

			}

	}

	void Display()

	{

		system("cls");

		Ticket *temp = new Ticket;

		temp = head; int count = 0;

		while (temp != NULL)

		{

			cout << "Your Name is:" << temp->FName<< endl;

			cout << "Your Ticket number is:" << temp->ticketNo << endl;

			cout << "Your seat number is:" << temp->seatNo << endl;

			cout << "Your Airline number is:" << temp->AirNo << endl;

			cout << "Your CNIC is:" << temp->cnic << endl;

			cout << "Position is:" << position << endl;

			cout << "Your Flight Date and time is:" << temp->ticketDate << endl;

			count++;

			temp = temp->next;

			cin.get();

			

		}

		if (count== 0)

		{

			cout << "Something is wrong" << endl;

			system("pause");

		}

	}

	void countfun()

	{

		system("cls");

		Ticket *temp = new Ticket;

		temp = head;

		while (temp!=NULL)

		{

			position++;

			temp = temp->next;

		}

		cout << "Total Nodes are:" << position << endl;

		cin.get();

	}

};

int main()

{

	

	int a = 0;

	Airline *Air1=new Airline;

	while (a != 8){

		cout << endl << endl;

		system("cls");

		cout << "******WITH ALPHABETICAL ORDER LINK LIST OPTION*****************" << endl << endl;

		cout << "Please Enter 1 to Create ticket" << endl << endl;

		cout << "Please Enter 2 to Display ticket" << endl << endl;

		cout << "Please Enter 3 to Check Reservation" << endl << endl;

		cout << "Plese Enter 4 to cancel Reservation:" << endl << endl;

		cout << "Please Enter 5 to sort Names Alphabeticali in link list" << endl << endl;

		cout << "Please Enter 6 to swap link list alphabetically" << endl << endl;

		cout << "Please Enter 7 to count the link list nodes" << endl << endl;

		cout << "Enter 8 to cancel the ticket:"; cin >> a; cin.ignore();

		switch (a){

		case 1:{

				   Air1->ResTicket();

				   break;

		}

		case 2:{

				   Air1->Display();

				   break;

		}

		case 3:

		{

				  Air1->IsResCheck();

				  break;

		}

		case 4:

		{

				  Air1->ResCancel();

				  break;

		}

		case 5:

		{

				  Air1->swapAlpha();

				  Air1->Display();

				  break;

		}

		case 6:

		{

				  Air1->sortFullData();

				  Air1->Display();

				  break;

		}

		case 7:

		{

				  Air1->countfun();

				  break;

		}

		default:

		{

				   if (a == 8){

					   cout << "PLease press Enter to cancel" << endl;

					   system("pause");

				   }

				   else

					   cout << "Option Not found" << endl;

				   cout << "please press enter" << endl;

				   cin.get();

		}

		}

	}

	getchar();

	getchar();

	return 0;

}     

          

       
 

Comments

Popular posts from this blog

Multiple inheritance,friend function and multiple file in oop(object oriented programming)

Concepts of OOP (object oriented programming)

Concepts in c++........