forked from kishanrajput23/Java-Projects-Collections
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
92 lines (80 loc) · 2.97 KB
/
Main.java
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package libraryApp;
import java.util.Scanner;
public class Main{
static Scanner scan = new Scanner(System.in);
static LibraryApp app = new LibraryApp();
public static void main(String[] args) {
int userChoice=0;
System.out.println("-----Welcome to the Library!-----\n");
do{
System.out.println("\n-----------------------------------");
System.out.println("1. Search book by Title keyword.");
System.out.println("2. Search book by ISBN number.");
System.out.println("3. Search book by Genre.");
System.out.println("4. Book Check In");
System.out.println("5. Book Check Out");
System.out.println("6. Exit from the library.");
System.out.println("-----------------------------------");
System.out.print("\nChoose any option: ");
userChoice = scan.nextInt();
scan.nextLine();
switch(userChoice){
case 1:
System.out.print("Enter the Title of Book: ");
app.findByTitle(scan.nextLine());
break;
case 2:
System.out.println("Enter ISBN number: ");
app.findByISBN(scan.nextInt());
break;
case 3:
System.out.println("Enter Genre: ");
app.findByGenre(scan.nextLine());
break;
case 4:
checkIn();
break;
case 5:
checkOut();
break;
case 6:
System.out.println("\nThanks for visiting. \nSee you again.");
break;
default:
System.out.println("\nInvalid Choice!");
}
}while(userChoice!=6);
}
//Checking book In
private static void checkIn() {
System.out.println("Enter Book's ISBN number : ");
int isbnNum = scan.nextInt();
getStatus(isbnNum);
int bookAvailable = app.findISBN(isbnNum);
if(bookAvailable==1) {
System.out.println(isbnNum);
app.withdrawBook(isbnNum);
System.out.println("Book CheckIn successful.");
getStatus(isbnNum);
}
else
System.out.printf("Book with %d ISBN number not Found in inventory.",isbnNum);
}
//Checking book Out
private static void checkOut() {
System.out.println("\nEnter Book's ISBN number : ");
int isbnNum = scan.nextInt();
int bookAvailable = app.findISBN(isbnNum);
if(bookAvailable==1) {
if(app.depositBook(isbnNum))
System.out.println("Book CheckOut successful.");
else
System.out.println("No Space for more Books.");
}
else
System.out.printf("Book with %d ISBN number not Found in inventory.",isbnNum);
}
private static void getStatus(int isbn) {
app.getStatus(isbn);
}
}