-
Notifications
You must be signed in to change notification settings - Fork 0
/
Client1.java
213 lines (175 loc) · 4.57 KB
/
Client1.java
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
package source;
//JAVA PACKAGES
import java.util.*;
import java.io.*;
public class Client1
{
//DATA MEMBERS
static String [] admin = {"ShivangiS","SiddhantG","SkandaS"};
static String [] pswd = {"01fb14ecs225","01fb14ecs240","01fb14ecs242"};
public static int adminL = admin.length;
public static int pswdL = pswd.length;
public static Graph gr= new Graph();
public static Scanner sc= new Scanner(System.in);
//FUNCTION FOR MAIN MENU
public static void mainM()
{
//FOR CLEAR SCREEN
System.out.print("\u001b[2J");
System.out.flush();
System.out.println("WELCOME TO INDIGO!!!");
gr.enter();
System.out.println("\n");
System.out.println("SYSTEM FOR ADMINISTRATION OF INDIGO...");
System.out.print("1.Login for Existing Admin\n2.Sign-Up for new Admin\n3.Exit\n\nEnter choice: ");
int y=sc.nextInt();
if(y==1)
{
// logA();
}
else if(y==2)
{
admn();
System.out.println("You're now registered on Indigo Admin System.");
// logA();
}
else if(y==3)
{
System.out.println("EXITTING!");
System.exit(0);
}
else
{
System.out.println("Invalid Input!");
mainM();
}
}
//FUNCTION FOR NEW ADMIN CREATION IN RECORD
public static void admn()
{
//FOR CLEAR SCREEN
System.out.print("\u001b[2J");
System.out.flush();
System.out.println("\n\n------------Welcome new Admin!------------\nPlease complete formalities of Sign-Up that follow...");
System.out.print("\nEnter new Admin Name: ");
String s=sc.next();
String [] adm= new String[++adminL];
for(int i=0; i<adminL-1; ++i)
{
adm[i]=admin[i];
}
adm[adminL-1]=s;
admin=adm;
System.out.print("Enter password new Admin "+s+": ");
String p=sc.next();
String [] pwd= new String[++pswdL];
for(int i=0; i<pswdL-1; ++i)
{
pwd[i]=pswd[i];
}
pwd[pswdL-1]=p;
pswd=pwd;
}
//FUNCTION FOR ACTIONS POST LOGIN OF ADMIN
public static void postLog()
{ String cho=""; int ch;
//FOR CLEAR SCREEN
System.out.print("\u001b[2J");
System.out.flush();
do
{
System.out.println("\n\n------------ WELCOME ADMIN ------------\n\n OPEARTIONS:\n1.Display all flights leaving from a given airport\n2.Display all flights reaching a given airport\n3.Search for flights from given Departure city to given Arrival City\n4.Add a flight\n5.Remove a flight\n6.Book a seat on a flight\n7.Cancel reservation for a given flight\n8.Sign Out\n");
System.out.print("Enter Choice: ");
ch= sc.nextInt();
switch(ch)
{
case 1://gr.disp();
break;
case 2://gr.disp2();
break;
case 3://gr.disp3();
break;
case 4://gr.AddFlight();
break;
case 5://gr.deleteFlight();
break;
case 6://gr.bookSeat();
break;
case 7:
case 8:System.out.println("\n");
//System.exit(0);
break;
default:System.out.println("Invalid Input");
}
if(ch!=8)
{
System.out.print("Do you want to continue?(y/n) :");
cho=sc.next();
}
}while(cho.equalsIgnoreCase("y") &&ch !=8);
System.out.println("------------SIGNING OUT!------------\n\n");
mainM();
}
//FUNCTION FOR LOGIN OF EXISTING ADMIN AND PASSWORD CHECKING
public static String logA(String name,String pwd)
{
String status="";
//FOR CLEAR SCREEN
System.out.print("\u001b[2J");
System.out.flush();
System.out.print("------------LOGIN------------\nEnter Admin Name: ");
// String name=sc.next();
boolean found=false; int fo=-1;
// String pwd="";
String cho="";
for(int i=0; i<admin.length; ++i)
{
if(name.equalsIgnoreCase(admin[i]))
{
found=true;
System.out.print("\n\tHello "+admin[i]+",\nEnter Password: ");
//pwd=sc.next();
fo=i;
}
}
if(!found)
status="NO SUCH ADMIN IN RECORD!";
if(found)
{
if(pswd[fo].equals(pwd))
{
status="Welcome "+admin[fo];
// postLog();
}
else
{
status="Invalid Password for "+admin[fo];
//mainM();
}
}
return status;
}
//main() FUNCTION
public static void main(String [] args)
{
/*System.out.println("WELCOME TO INDIGO!!!");
gr.enter();
System.out.println("\n");
System.out.println("SYSTEM FOR ADMINISTRATION OF INDIGO...");
System.out.print("1.Login for Existing Admin\n2.Sign-Up for new Admin\nEnter choice: ");
int y=sc.nextInt();
if(y==1)
{
logA();
}
else if(y==2)
{
admn();
System.out.println("You're now registered on Indigo Admin System.");
logA();
}
else
System.out.println("Invalid Input!");*/
mainM();
}
}