-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
178 lines (139 loc) · 5.09 KB
/
main.cpp
File metadata and controls
178 lines (139 loc) · 5.09 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
//
// main.cpp
// Final Project
//
// Created by Ainur Aman on 2021. 04. 13..
//
#include <iostream>
#include <fstream>
#include "airplane.h"
#include "Ticket.h"
#include "Storage.h"
#include "Reservation.h"
#include <string.h>
using namespace std;
int line_num(){ //function to identify the line number of file
ifstream FFilein;
FFilein.open("/Users/ainur/Desktop/programming labs/C++SecondSemester/my project/Final Project/Final Project/Flight.txt");
int number_of_lines = 0;
string line;
while (getline(FFilein, line)){
++number_of_lines;}
cout<<number_of_lines<<endl;
FFilein.close();
return number_of_lines;
}
void Continue(){ //function to ask after tasks weather user wants to continue working with the program
int choice;
cout<< "\n\n\n";
cout << "\t\t\t\t\t\t\t\t\t\t ================================================\n";
cout << "\t\t\t\t\t\t\t\t\t\t Do You want to continue? \n";
cout << "\t\t\t\t\t\t\t\t\t\t ================================================\n\n\n";
cout << "\t\t\t\t\t\t\t\t\t\t-------------------------------------------------\n";
cout << "\t\t\t\t\t\t\t\t\t\t|\t1. Go back to Menu \t\t|\n";
cout << "\t\t\t\t\t\t\t\t\t\t-------------------------------------------------\n";
cout << "\t\t\t\t\t\t\t\t\t\t|\t2. Finish \t\t|\n";
cout << "\t\t\t\t\t\t\t\t\t\t-------------------------------------------------\n";
cout << "\n\t\t\t\t\t\t\t\t\t\tEnter your choice:-> ";
cin >> choice;
switch (choice)
{
case 1:
throw 0;
break;
case 2:
cout << "Goodby:)";
break;
default:
cout << "\n\t\t\t\t\t Choose valid option!!! \t\t\t\n";
system("pause");
Continue();
}
}
void Menu() //Menu of the program containing all necessery functions
{
Database dt;
Reserve r;
int fnum, ticketid;
dt.getflightinfo(); //gets info from file and puts to dynamic memory
r.getfromfile(); //gets info from file and puts to dynamic memory
int choice;
// MENU ITEMS
cout << "\n\n\n";
cout << "\t\t\t\t\t\t\t\t\t\t ================================================\n";
cout << "\t\t\t\t\t\t\t\t\t\t\t################::Menu::################\n";
cout << "\t\t\t\t\t\t\t\t\t\t ================================================\n\n\n";
cout << "\t\t\t\t\t\t\t\t\t\t-------------------------------------------------\n";
cout << "\t\t\t\t\t\t\t\t\t\t|\t1. Reserve Ticket \t\t|\n";
cout << "\t\t\t\t\t\t\t\t\t\t-------------------------------------------------\n";
cout << "\t\t\t\t\t\t\t\t\t\t|\t2. View available flights \t\t|\n";
cout << "\t\t\t\t\t\t\t\t\t\t-------------------------------------------------\n";
cout << "\t\t\t\t\t\t\t\t\t\t|\t3. View Booked Ticket \t\t\t|\n";
cout << "\t\t\t\t\t\t\t\t\t\t-------------------------------------------------\n";
cout << "\t\t\t\t\t\t\t\t\t\t|\t4. BACK \t\t\t|\n";
cout << "\t\t\t\t\t\t\t\t\t\t-------------------------------------------------\n";
cout << "\t\t\t\t\t\t\t\t\t\t|\t5. Finish \t\t\t|\n";
cout << "\t\t\t\t\t\t\t\t\t\t-------------------------------------------------\n\n";
cout << "\n\t\t\t\t\t\t\t\t\t\tEnter your choice:-> ";
cin >> choice;
switch (choice)
{
case 1:
try{
fnum= dt.selectcities();
r.booking(fnum);
r.savetofile();
try{
Continue();
}catch(int e){
Menu();
}
}catch(int e){
cout<<"No results found. Please try again!";
Menu();
}
break;
case 2:
dt.print(); //prints all available flight info
cout << "\n\n";
try{
Continue();
}catch(int e){
Menu();
}
break;
case 3:
cout<<"Please enter your ticket ID: ";
cin>>ticketid;
try{
r.searchticket(ticketid);
try{
Continue();
}catch(int e){
Menu();
}
}catch(int e){
if(e==0){
cout<<"\t\t\t\t\t\t\t\t\t\t No match with this Ticket Id! Please try again "<<endl;
}
Menu();
}
break;
case 4:
Menu();
break;
case 5:
system("cls");
break;
default:
cout << "\n\t\t\t\t\t Choose valid option!!! \t\t\t\n";
system("pause");
Menu();
}
}
int main(){
cout << "\n\n";
cout<<"\t\t\t\t\t******************** Welcome to the Airplane Reservation system! ********************"<<endl;
Menu();
return 0;
}