-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAdmin.java
More file actions
60 lines (54 loc) · 2.24 KB
/
Admin.java
File metadata and controls
60 lines (54 loc) · 2.24 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
import java.util.Scanner;
public class Admin extends User {
public Admin(String id, String name) {
super(id, name);
}
@Override
public void displayMenu(Library library, Scanner input) {
int choice = 0;
System.out.println("Welcome Admin " + getName());
while(choice != 6) {
System.out.println("\nWhat would you like to do:");
System.out.println("1. Add a book");
System.out.println("2. View all past transactions");
System.out.println("3. Remove book from availability");
System.out.println("4. Display available books");
System.out.println("5. Display currently checked out books");
System.out.println("6. Exit");
choice = input.nextInt();
input.nextLine();
switch(choice) {
case 1:
System.out.println("Enter book title:");
String title = input.nextLine();
System.out.println("Enter author:");
String author = input.nextLine();
System.out.println("Enter the year written:");
String year = input.nextLine();
String id = "B" + System.currentTimeMillis();
library.addBook(new Book(id, title, author, year, true));
System.out.println("Book added successfully.");
break;
case 2:
FileUtils.displayAllTransactions();
break;
case 3:
System.out.println("Enter book to remove (title or ID):");
String removeTitle = input.nextLine();
library.removeBook(removeTitle);
break;
case 4:
library.displayAvailableBooks();
break;
case 5:
library.displayCurrentlyCheckedOut();
break;
case 6:
System.out.println("Exiting...");
break;
default:
System.out.println("Invalid choice.");
}
}
}
}