-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibraryManagementSystem.java
More file actions
60 lines (55 loc) · 2.31 KB
/
Copy pathLibraryManagementSystem.java
File metadata and controls
60 lines (55 loc) · 2.31 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
package main;
import services.BookService;
import services.IssueService;
import utils.InputHelper;
import models.Book;
import java.util.List;
public class LibraryManagementSystem {
public static void main(String[] args) {
while (true) {
System.out.println("\nLibrary Management System");
System.out.println("1. Add Book");
System.out.println("2. View Books");
System.out.println("3. Issue Book");
System.out.println("4. Return Book");
System.out.println("5. Delete Book");
System.out.println("6. Exit");
System.out.print("Choose an option: ");
int choice = InputHelper.getInt();
InputHelper.getString();
switch (choice) {
case 1 -> {
System.out.print("Enter book title: ");
String title = InputHelper.getString();
System.out.print("Enter book author: ");
String author = InputHelper.getString();
BookService.addBook(title, author);
}
case 2 -> {
List<Book> books = BookService.getAllBooks();
books.forEach(book -> System.out.printf("ID: %d | Title: %s | Author: %s | Available: %s%n",
book.getId(), book.getTitle(), book.getAuthor(), book.isAvailable() ? "Yes" : "No"));
}
case 3 -> {
System.out.print("Enter book ID to issue: ");
int bookId = InputHelper.getInt();
InputHelper.getString();
System.out.print("Enter your name: ");
String issuedTo = InputHelper.getString();
IssueService.issueBook(bookId, issuedTo);
}
case 4 -> {
System.out.print("Enter book ID to return: ");
int bookId = InputHelper.getInt();
IssueService.returnBook(bookId);
}
case 5 -> {
System.out.print("Enter book ID to delete: ");
int bookId = InputHelper.getInt();
BookService.deleteBook(bookId);
}
case 6 -> System.exit(0);
}
}
}
}