-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.java
56 lines (49 loc) · 1.48 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
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
public class admin implements observer{
static System system;
admin(System sys){
system = sys;
}
//add one number to user list and restart engine
public static void addNumber() {
Scanner input = new Scanner(java.lang.System.in);
java.lang.System.out.println("Type a number you want to add");
int number = Integer.parseInt(input.nextLine());
boolean check = system.checkExist(number);
if(check) {
java.lang.System.out.println("number already exists on the system");
return;
}
else {
system.addUser(number);
system.updateEngine();
}
}
//remove one number in the first of the list, and restart engine
public static void deleteNumber() {
system.removeUser();
system.updateEngine();
}
public void update() {
// TODO Auto-generated method stub
try {
PhoneSystemLog templ = new PhoneSystemLog();
String line = templ.nextL();
while(line != null) {
java.lang.System.out.println(line);
line = templ.nextL();
}
}
catch(FileNotFoundException e){
java.lang.System.out.println("Error creating base log file. file not found");
}
catch(IOException e){
java.lang.System.out.println("Error creating base log file. IO");
}
}
}