Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class Library {
- public Library(String name) {
- this.name = name;
- this.Books = new ArrayList<Book>();
- }
- String name;
- ArrayList<Book> Books;
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public ArrayList<Book> getBooks() {
- return Books;
- }
- public void setBooks(ArrayList<Book> Books) {
- this.Books = Books;
- }
- public void AddBook(Book book){
- this.Books.add(book);
- }
- public Book FindBookByAuthor(String author){
- return Books.stream()
- .filter((Book) -> Book.getAuthor().equals(author))
- .findFirst()
- .orElse(null);
- }
- public String BookInfo(Book book){
- return "Title: " + book.getTitle() + "\n" + "Author: "
- + book.getAuthor() + "\n" + "Publishing House: " + book.getPublishingHouse() + "\n"
- + "Date: " + book.getDate() + "\n" + "ISBN: " + book.getIsbn();
- }
- public void RemoveBook(Book book){
- if(!Books.contains(book)){
- return;
- }
- Books.remove(book);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement