-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdmin.java
More file actions
63 lines (52 loc) · 1.63 KB
/
Admin.java
File metadata and controls
63 lines (52 loc) · 1.63 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
56
57
58
59
60
61
62
63
package org.example;
import java.util.ArrayList;
public class Admin {
// private ArrayList<User> admin;
private boolean admins;
private String report;
public Admin(){}
public Admin(boolean admins){
this.admins = admins;
}
//to add any user as admin
public void addAdmin(User user){
user.setAdmin(true);
System.out.println(user.getUsername() + "has set as admin");
}
//remove the user from admin
public void removeAdmin(User user){
user.setAdmin(false);
System.out.println(user.getUsername() + "has remove from admin");
}
public void setAdmins(boolean admins) {
this.admins = admins;
}
public boolean getAdmins(){
return admins;
}
//to delete any user account
public boolean deleteAccount(String username){
LoginSystem userAccount = new LoginSystem();
if(!admins) System.out.println("Only admins are allowed to delete the account");
else{
if(userAccount.login_info.size() == 0) {
System.out.println("There is no account left");
return false;
}
else{
for (int i = 0; i < userAccount.login_info.size(); i++) {
if(userAccount.login_info.get(i).equals(username)){
userAccount.login_info.remove(i);
return true;
}
}
}
}
return false;
}
public void deletePosts(User users){
if(!admins) System.out.println("Only admins are allowed to delete the posts");
else{
}
}
}