forked from kishanrajput23/Java-Projects-Collections
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLibrary Catalog System.java
81 lines (70 loc) · 2.23 KB
/
Library Catalog System.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
import java.util.ArrayList;
import java.util.Scanner;
class Book {
private String title;
private String author;
private String isbn;
private String category;
private boolean available;
public Book(String title, String author, String isbn, String category) {
this.title = title;
this.author = author;
this.isbn = isbn;
this.category = category;
this.available = true;
}
// Getters and setters for book details
public boolean isAvailable() {
return available;
}
public void checkOut() {
available = false;
}
public void returnBook() {
available = true;
}
}
public class LibraryCatalogSystem {
private static ArrayList<Book> catalog = new ArrayList<>();
private static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
while (true) {
displayMenu();
int choice = scanner.nextInt();
scanner.nextLine(); // Consume newline character
switch (choice) {
case 1:
addBook();
break;
case 2:
searchBooks();
break;
case 3:
viewBookDetails();
break;
case 4:
checkoutBook();
break;
case 5:
returnBook();
break;
case 6:
System.out.println("Goodbye!");
System.exit(0);
default:
System.out.println("Invalid choice. Please try again.");
}
}
}
// Implement methods for adding, searching, viewing, checking out, and returning books
private static void displayMenu() {
System.out.println("\nLibrary Catalog System");
System.out.println("1. Add a new book");
System.out.println("2. Search books");
System.out.println("3. View book details");
System.out.println("4. Checkout a book");
System.out.println("5. Return a book");
System.out.println("6. Exit");
System.out.print("Enter your choice: ");
}
}