|
| 1 | +import java.util.*; |
| 2 | + |
| 3 | +class Authentication{ |
| 4 | + static HashMap<String,String> login = new HashMap<String,String>(); |
| 5 | + static Scanner in = new Scanner(System.in); |
| 6 | + List<Integer> Pnr_no = new ArrayList<Integer>(); |
| 7 | + Dictionary trainList = new Hashtable(); |
| 8 | + // Dictionary passgr_detail = new Hashtable(); |
| 9 | + HashMap<String,String[]> passengers = new HashMap<String,String[]>(); |
| 10 | + Dictionary<Integer, String> passgr_detail = new Hashtable<Integer, String>(); |
| 11 | + |
| 12 | + public static void Start() |
| 13 | + {} |
| 14 | + |
| 15 | + |
| 16 | + void Sign_up() { |
| 17 | + |
| 18 | + String username,password; |
| 19 | + System.out.println("Enter Username"); |
| 20 | + username=in.nextLine(); |
| 21 | + System.out.println("Enter Password"); |
| 22 | + password=in.nextLine(); |
| 23 | + login.put(username,password); |
| 24 | + |
| 25 | + } |
| 26 | + |
| 27 | + void Sign_in() { |
| 28 | + String inusername,inpassword; |
| 29 | + int ch; |
| 30 | + Scanner in = new Scanner(System.in); |
| 31 | + System.out.println("Enter Username"); |
| 32 | + inusername=in.nextLine(); |
| 33 | + System.out.println("Enter Password"); |
| 34 | + inpassword=in.nextLine(); |
| 35 | + |
| 36 | + |
| 37 | + //Check whether entered password with username |
| 38 | + if (inpassword.equals(login.get(inusername))){ |
| 39 | + options(); |
| 40 | + |
| 41 | + } |
| 42 | + else |
| 43 | + { |
| 44 | + System.out.println("Password invalid"); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + public void options() { |
| 49 | + System.out.println("1.Reservation Details"); |
| 50 | + System.out.println("2.Cancellation"); |
| 51 | + System.out.println("Enter Choice"); |
| 52 | + int ch = in.nextInt(); |
| 53 | + |
| 54 | + switch (ch){ |
| 55 | + |
| 56 | + case 1: |
| 57 | + Reservation_sys(); |
| 58 | + break; |
| 59 | + |
| 60 | + case 2: |
| 61 | + cancellation(); |
| 62 | + break; |
| 63 | + |
| 64 | + default: |
| 65 | + System.out.println("Enter Valid Choice"); |
| 66 | + |
| 67 | + } |
| 68 | + |
| 69 | + } |
| 70 | + |
| 71 | + public void cancellation() { |
| 72 | + Integer PNR_no; |
| 73 | + System.out.println("Enter PNR Number"); |
| 74 | + PNR_no = in.nextInt(); |
| 75 | + |
| 76 | + |
| 77 | + System.out.println("Details" + passgr_detail.get(trainList)); |
| 78 | + System.out.println("\n"); |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + options(); |
| 83 | + |
| 84 | + } |
| 85 | + |
| 86 | + public void Reservation_sys() { |
| 87 | + Scanner in =new Scanner(System.in); |
| 88 | + |
| 89 | + |
| 90 | + trainList.put("10022","LTT"); |
| 91 | + trainList.put("10023","Pudocherry Express"); |
| 92 | + trainList.put("10024","Chennai Express"); |
| 93 | + String train_no; |
| 94 | + String class_type,date,from_place,to_place; |
| 95 | + |
| 96 | + int n =trainList.size(); |
| 97 | + for (int i = 0; i < n; i++) { |
| 98 | + |
| 99 | + |
| 100 | + System.out.println("Enter Train Number"); |
| 101 | + System.out.println("10022\n" + "10023\n" + "10024\n"); |
| 102 | + train_no = in.nextLine(); |
| 103 | + passgr_detail.put(1, train_no); |
| 104 | + //passgr_detail.put((String) trainList.get(train_no)); |
| 105 | + System.out.println("Train Name is :" + trainList.get(train_no)); |
| 106 | + System.out.println("Enter Class type "); |
| 107 | + class_type = in.nextLine(); |
| 108 | + passgr_detail.put(1,class_type); |
| 109 | + System.out.println("Enter Date of Journey"); |
| 110 | + date = in.nextLine(); |
| 111 | + passgr_detail.put(1, date); |
| 112 | + System.out.println("Enter From place :"); |
| 113 | + from_place = in.nextLine(); |
| 114 | + passgr_detail.put(1,from_place); |
| 115 | + System.out.println("Enter Destination place"); |
| 116 | + to_place = in.nextLine(); |
| 117 | + passgr_detail.put(1,to_place); |
| 118 | + System.out.println("Enter insert"); |
| 119 | + String insert = in.nextLine(); |
| 120 | + options(); |
| 121 | + |
| 122 | + } |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | + } |
| 128 | +} |
| 129 | + |
| 130 | +public class TASK_1 { |
| 131 | + public static void main(String[] args) { |
| 132 | + Scanner in = new Scanner(System.in); |
| 133 | + Authentication obj = new Authentication(); |
| 134 | + do { |
| 135 | + System.out.println("1.Sign In"); |
| 136 | + System.out.println("2.Sign Up"); |
| 137 | + System.out.println("Enter Choice"); |
| 138 | + int ch = in.nextInt(); |
| 139 | + switch (ch) { |
| 140 | + case 1 -> obj.Sign_in(); |
| 141 | + case 2 -> obj.Sign_up(); |
| 142 | + default -> System.out.println("Enter valid choice"); |
| 143 | + } |
| 144 | + }while (true); |
| 145 | + } |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | +} |
| 150 | + |
0 commit comments