-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNormalUser.java
More file actions
55 lines (43 loc) · 1.25 KB
/
NormalUser.java
File metadata and controls
55 lines (43 loc) · 1.25 KB
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
package HW7Exercise2;
public class NormalUser extends User implements NormalUserInterface {
private int id;
private PhoneBookDirectory phoneBookDirectory;
public NormalUser(String username, String password, int id, PhoneBookDirectory phoneBookDirectory) {
super(username, password);
this.id = id;
this.phoneBookDirectory = phoneBookDirectory;
}
@Override
public void PrintUserInfo() {
super.PrintUserInfo();
System.out.println("User id: " + id);
}
@Override
public void addEntry(PhoneBookEntry entry) {
phoneBookDirectory.addEntry(entry);
}
@Override
public void editEntry(String firstName, String lastName) {
phoneBookDirectory.Edit(firstName, lastName);
}
@Override
public void sortPhoneBook() {
phoneBookDirectory.SortbyID();
}
@Override
public void searchByPhoneNumber(String phoneNumber) {
int result = phoneBookDirectory.LinearSearchByPhoneNumber(phoneNumber);
if (result == 1) {
System.out.println("Phone number found.");
} else {
System.out.println("Phone number not found.");
}
}
// Getters and Setters for email
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}