-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
40 lines (36 loc) · 1.38 KB
/
Main.java
File metadata and controls
40 lines (36 loc) · 1.38 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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Library library = new Library();
Scanner sc = new Scanner(System.in);
library.addBook(new Book("Java Programming", "James Gosling"));
library.addBook(new Book("Python Basics", "Guido van Rossum"));
int choice;
do {
System.out.println("\n1. Show Books\n2. Issue Book\n3. Return Book\n4. Exit");
System.out.print("Enter choice: ");
choice = sc.nextInt();
sc.nextLine(); // consume newline
switch (choice) {
case 1:
library.showAllBooks();
break;
case 2:
System.out.print("Enter book title to issue: ");
String titleToIssue = sc.nextLine();
library.issueBook(titleToIssue);
break;
case 3:
System.out.print("Enter book title to return: ");
String titleToReturn = sc.nextLine();
library.returnBook(titleToReturn);
break;
case 4:
System.out.println("Exiting...");
break;
default:
System.out.println("Invalid choice.");
}
} while (choice != 4);
}
}