-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
53 lines (48 loc) · 1.78 KB
/
Copy pathMain.java
File metadata and controls
53 lines (48 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
53
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
App app = new App();
while (true) {
System.out.println("Choose an option:");
System.out.println("1. List all books");
System.out.println("2. List all people");
System.out.println("3. Create a person");
System.out.println("4. Create a book");
System.out.println("5. Create a rental");
System.out.println("6. List rentals for a person");
System.out.println("7. Quit");
System.out.print("Enter your choice: ");
int choice = scanner.nextInt();
scanner.nextLine(); // Consume the newline character
switch (choice) {
case 1:
app.listAllBooks();
break;
case 2:
app.listAllPeople();
break;
case 3:
app.createPerson();
break;
case 4:
app.createBook();
break;
case 5:
app.createRental();
break;
case 6:
System.out.print("Enter the person ID: ");
int personId = scanner.nextInt();
app.listRentalsForPerson(personId);
break;
case 7:
System.out.println("Exiting the application...");
return;
default:
System.out.println("Invalid choice. Please try again.");
}
System.out.println(); // Add a newline for better readability
}
}
}