-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTASK_1.java
150 lines (110 loc) · 4.12 KB
/
TASK_1.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
import java.util.*;
class Authentication{
static HashMap<String,String> login = new HashMap<String,String>();
static Scanner in = new Scanner(System.in);
List<Integer> Pnr_no = new ArrayList<Integer>();
Dictionary trainList = new Hashtable();
// Dictionary passgr_detail = new Hashtable();
HashMap<String,String[]> passengers = new HashMap<String,String[]>();
Dictionary<Integer, String> passgr_detail = new Hashtable<Integer, String>();
public static void Start()
{}
void Sign_up() {
String username,password;
System.out.println("Enter Username");
username=in.nextLine();
System.out.println("Enter Password");
password=in.nextLine();
login.put(username,password);
}
void Sign_in() {
String inusername,inpassword;
int ch;
Scanner in = new Scanner(System.in);
System.out.println("Enter Username");
inusername=in.nextLine();
System.out.println("Enter Password");
inpassword=in.nextLine();
//Check whether entered password with username
if (inpassword.equals(login.get(inusername))){
options();
}
else
{
System.out.println("Password invalid");
}
}
public void options() {
System.out.println("1.Reservation Details");
System.out.println("2.Cancellation");
System.out.println("Enter Choice");
int ch = in.nextInt();
switch (ch){
case 1:
Reservation_sys();
break;
case 2:
cancellation();
break;
default:
System.out.println("Enter Valid Choice");
}
}
public void cancellation() {
Integer PNR_no;
System.out.println("Enter PNR Number");
PNR_no = in.nextInt();
System.out.println("Details" + passgr_detail.get(trainList));
System.out.println("\n");
options();
}
public void Reservation_sys() {
Scanner in =new Scanner(System.in);
trainList.put("10022","LTT");
trainList.put("10023","Pudocherry Express");
trainList.put("10024","Chennai Express");
String train_no;
String class_type,date,from_place,to_place;
int n =trainList.size();
for (int i = 0; i < n; i++) {
System.out.println("Enter Train Number");
System.out.println("10022\n" + "10023\n" + "10024\n");
train_no = in.nextLine();
passgr_detail.put(1, train_no);
//passgr_detail.put((String) trainList.get(train_no));
System.out.println("Train Name is :" + trainList.get(train_no));
System.out.println("Enter Class type ");
class_type = in.nextLine();
passgr_detail.put(1,class_type);
System.out.println("Enter Date of Journey");
date = in.nextLine();
passgr_detail.put(1, date);
System.out.println("Enter From place :");
from_place = in.nextLine();
passgr_detail.put(1,from_place);
System.out.println("Enter Destination place");
to_place = in.nextLine();
passgr_detail.put(1,to_place);
System.out.println("Enter insert");
String insert = in.nextLine();
options();
}
}
}
public class TASK_1 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Authentication obj = new Authentication();
do {
System.out.println("1.Sign In");
System.out.println("2.Sign Up");
System.out.println("Enter Choice");
int ch = in.nextInt();
switch (ch) {
case 1 -> obj.Sign_in();
case 2 -> obj.Sign_up();
default -> System.out.println("Enter valid choice");
}
}while (true);
}
}