-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
73 lines (62 loc) · 2.5 KB
/
Copy pathMain.java
File metadata and controls
73 lines (62 loc) · 2.5 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
61
62
63
64
65
66
67
68
69
70
71
72
73
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Library myLibrary = new Library();
Scanner sc = new Scanner(System.in);
boolean running = true;
System.out.println("=== WELCOME TO THE CODING PARTNER LIBRARY ===");
while (running) {
System.out.println("\n~~~ MENU INFO ~~~");
System.out.println("1. Add ");
System.out.println("2. Checkout ");
System.out.println("3. Return Book (With ISBN no.) ");
System.out.println("4. Find Book ( With ISBN no.");
System.out.println("5. Stats ");
System.out.println("6. Exit ");
System.out.print("Select an Option: ");
String choice = sc.nextLine();
switch (choice) {
case "1":
System.out.print("Enter ISBN: ");
String isbn = sc.nextLine();
System.out.print("Enter Title: ");
String title = sc.nextLine();
//Safety Check: so fields can't be empty filled with junk data
if (isbn.trim().isEmpty() || title.trim().isEmpty()) {
System.out.println(">>> Error: ISBN and Title cannot be empty!");
}
else {
myLibrary.addBook(isbn, title);
}
break;
case "2": {
System.out.print("Enter ISBN to checkout: ");
String searchIsbn = sc.nextLine();
myLibrary.checkOutBook(searchIsbn);
break;
}
case "3":
System.out.print("Enter ISBN to return: ");
String returnIsbn = sc.nextLine();
myLibrary.returnBook(returnIsbn);
break;
case "4": {
System.out.print("Enter ISBN to search: ");
String searchIsbn = sc.nextLine();
myLibrary.findBook(searchIsbn);
break;
}
case "5":
myLibrary.showStats();
break;
case "6":
running = false;
break;
default:
System.out.println("Invalid Option!");
break;
}
}
sc.close();
}
}