Note Java
Note Java
Scanner;
class Book {
class bookLinkedList {
private Book head;
public bookLinkedList() {
this.head = null;
}
if (head.getISBN().equals(ISBN)) {
head = head.getNext();
System.out.println("Book deleted successfully.");
return;
}
if (current == null) {
System.out.println("Book not found.");
} else {
previous.setNext(current.getNext());
System.out.println("Book deleted successfully.");
}
}
if (current == null) {
System.out.println("Book not found.");
} else {
System.out.println("Book details:");
System.out.println("Title: " + current.getTitle());
System.out.println("ISBN: " + current.getISBN());
System.out.println("Author: " + current.getAuthor());
System.out.println("Publisher: " + current.getPublisher());
}
}
while (true) {
switch (choice) {
case 1:
System.out.println("Enter title:");
String title = scanner.nextLine();
System.out.println("Enter ISBN:");
String isbn = scanner.nextLine();
System.out.println("Enter author:");
String author =
scanner.nextLine();
System.out.println("Enter publisher:");
String publisher = scanner.nextLine();
bookList.addBook(title, isbn, author, publisher);
System.out.println("Book added");
break;
case 2:
System.out.println("Enter ISBN of book to delete:");
isbn = scanner.nextLine();
bookList.deleteBook(isbn);
break;
case 3:
System.out.println("Enter ISBN of book to find:");
isbn = scanner.nextLine();
bookList.findBook(isbn);
break;
case 4:
bookList.printBooks();
break;
case 5:
System.exit(0);
default:
System.out.println("Invalid choice, please try again");
}
}
}
}