-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdminManager.java
70 lines (63 loc) · 1.96 KB
/
AdminManager.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
package projects.onlineBookReader;
import java.util.Scanner;
public class AdminManager extends User {
Scanner sc = new Scanner(System.in);
private CustomerManager customerManager;
private BookManager bookManager;
public AdminManager(String name, String userName, String passWord, String email) {
super(name, userName, passWord, email);
customerManager = new CustomerManager();
bookManager = new BookManager(); // default values
}
public void doLogin(CustomerManager cm, BookManager bm) {
this.customerManager = cm;
this.bookManager = bm;
System.out.print("Enter user name: ");
String tempUserName = sc.nextLine();
System.out.print("Enter password: ");
String tempPassword = sc.nextLine();
if (!this.getUserName().equals(tempUserName) || !this.getPassword().equals(tempPassword)) {
System.out.println("Invalid username or password.");
return;
}
go();
}
private void go() {
System.out.println("Hello " + getName() + " | Admin Veiw");
while (true) {
int choice = menu();
if (choice == 1)
viewProfile();
else if (choice == 2) {
bookManager.read_and_addBook();
} else if (choice == 3) {
bookManager.listBooks();
bookManager.removeBook();
} else if (choice == 4) {
bookManager.listBooks();
} else if (choice == 5) {
customerManager.listCustomers();
} else if (choice == 6) {
customerManager.listCustomers();
customerManager.removeCustomer();
} else if (choice == 7) {
System.out.println("Goodbye :)\n");
break;
} else {
System.out.println("Invalid choice. try again");
}
}
}
private int menu() {
System.out.println("Menu: ");
System.out.println("\t 1: View Profile");
System.out.println("\t 2: Add Book");
System.out.println("\t 3: Remove Book");
System.out.println("\t 4: List All Books");
System.out.println("\t 5: List System Customers");
System.out.println("\t 6: Remove Customer");
System.out.println("\t 7: Logout");
int choice = sc.nextInt();
return choice;
}
}