-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdmin.java
105 lines (72 loc) · 2.2 KB
/
Admin.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
import java.io.*;
import java.util.*;
public class Admin{
ArrayList<String> name = new ArrayList<String>();
ArrayList<String> password = new ArrayList<String>();
String n;
public Admin() {
try{
File file = new File("admin_details.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while((line=br.readLine())!=null){
String temp[] = line.split(",");
name.add(temp[0]);
password.add(temp[1]);
}
br.close();
}catch(FileNotFoundException fex){
System.out.println("It's look like admin_details.txt file has been deleted");
System.out.println("Please re-initialize it with name,password");
}catch(Exception ex){
ex.printStackTrace();
}
}
public void display() throws Exception{
do {
new clear().go();
// Scanner input = new Scanner(System.in);
System.out.println("\nWelcome " + n);
System.out.println("\nChoose from the following");
System.out.println("\n1.Choose Channels");
System.out.println("2.Show subscribe channels");
System.out.println("3.Remove subscribe channels");
System.out.println("4.Log out");
//System.out.println("5.exit");
System.out.print("\nYour choice ");
int choice = -1; // = input.nextInt();
try{
choice = input.nextInt();
String garbage = input.nextLine();
}catch(InputMismatchException iex){
choice = -1;
}catch(NoSuchElementException ex){
System.out.println("Something is not looking right");
System.out.println("I don't want to terminate but...you know that ....!ahh");
System.exit(0);
}
switch(choice){
case 1:
getSubscription();
break;
case 2:
showSubscription();
break;
case 3:
removeSubscription();
break;
case 4:
return;
/* case 5:
System.exit(0); */
default:
System.out.println("\nPlease enter your choice wisely\n");
}
System.out.println("\n\nPlease press enter...");
System.in.read();
String garbage = input.nextLine();
input = null;
input = new Scanner(System.in);
//display();
}while(true);
}