-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStudent.java
More file actions
52 lines (45 loc) · 1.78 KB
/
Student.java
File metadata and controls
52 lines (45 loc) · 1.78 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
import java.util.Scanner;
public class Student extends User {
public Student(String id, String name) {
super(id, name);
}
@Override
public void displayMenu(Library library, Scanner input) {
int choice = 0;
System.out.println("Welcome " + getName());
// Show current checkout status
String currentBook = FileUtils.getCurrentlyCheckedOutBook(getName());
if (currentBook != null) {
System.out.println("You currently have checked out: " + currentBook);
}
while(choice != 4) {
System.out.println("\nWhat would you like to do:");
System.out.println("1. Display available books");
System.out.println("2. Checkout a book");
System.out.println("3. Return a book");
System.out.println("4. Exit");
choice = input.nextInt();
input.nextLine();
switch(choice) {
case 1:
library.displayAvailableBooks();
break;
case 2:
System.out.println("Enter book to checkout (title or ID):");
String checkoutTitle = input.nextLine();
library.checkoutBook(checkoutTitle, getName());
break;
case 3:
System.out.println("Enter book to return (title):");
String returnTitle = input.nextLine();
library.returnBook(returnTitle, getName());
break;
case 4:
System.out.println("Exiting...");
break;
default:
System.out.println("Invalid choice.");
}
}
}
}