-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
144 lines (125 loc) · 3.37 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <string>
#include "nodeList.h"
#include "list.h"
/*
Victoria C
Double Linked List Reservation Program
5/13/13
*/
using namespace std;
int randTicket(int low, int high);
void clear();
int main()
{
srand((unsigned)time(NULL));
nodeList* nl = new nodeList();
while (true)
{
int choice;
cout << "::AIRLINE RESERVATION SYSTEM::\n\n"
<< "1. Reserve a ticket\n"
<< "2. Cancel a ticket\n"
<< "3. Check a ticket\n"
<< "4. Display Passengers\n"
<< "5. EXIT\n"
<< "Choice: ";
cin >> choice;
switch (choice)
{
case 1:
{
cout << "Reserving a ticket\n\n";
cout << "Enter Name: ";
string name;
cin >> name;
int tix = randTicket(0,5);
list* newTicket = new list(name,tix);
nl->addToHead(newTicket);
cout << "Ticket reservation sucessful!\n";
cout << "Your ticket information is the latest one\n";
cout << "Please keep a copy for your records\n";
nl->printList();
cout << "\n";
break;
}
case 2:
{
cout << "Canceling a ticket\n\n";
cout << "Enter ticket number: ";
int ticketToFind;
cin >> ticketToFind;
list* ticketToDelete = nl->FindNodeByTicket(ticketToFind);
if (ticketToDelete != NULL)
{
nl->deleteNode(ticketToDelete);
cout << "Ticket deletion sucessful";
}
else
cout << "unable to locate ticket";
break;
}
case 3:
{
cout << "Checking a ticket\n\n";
int ticketToFind;
cout << "enter ticket";
cin >> ticketToFind;
list* foundTicket = nl->FindNodeByTicket(ticketToFind);
if (foundTicket != NULL)
{
cout << *foundTicket;
}
else
{
cout << "no ticket found";
}
break;
}
case 4:
{
cout << "Displaying Passengers\n\n";
nl->printList();
break;
}
case 5:
{
cout << "Now exiting program\n\n";
clear();
return 0;
break;
}
default:
{
cout << "Invalid Input\n\n";
return 0;
}
}
}
return 0;
}
int randTicket(int low, int high)
{//randomizes ticket
int num1;
int range=(high-low);
int num = rand() * range / RAND_MAX + low ;
return(num1);
}
void clear()
{ //free up clutter
int a = 1;
int b = 100;
do
{
printf("\n");
a++;
}
while( a < b );
cout << "\t\t\tThe sky is the limit\n\n";
cout << "\t\t \\__________( )__________/\n";
cout << "\t\t o' `o ";
}