diff --git a/src/main/java/org/ntlab/citrusserver/repositories/PublicBookManager.java b/src/main/java/org/ntlab/citrusserver/repositories/PublicBookManager.java index 42bdabf..8837331 100644 --- a/src/main/java/org/ntlab/citrusserver/repositories/PublicBookManager.java +++ b/src/main/java/org/ntlab/citrusserver/repositories/PublicBookManager.java @@ -11,16 +11,25 @@ private final BookManager bookManager; + private HashSet publicBooks = new HashSet<>(); + public PublicBookManager(BookManager bookManager) { this.bookManager = bookManager; + this.bookManager.addListener(this); } public ArrayList getAllPublicBooks(){ - return null; + return new ArrayList<>(this.publicBooks); } public ArrayList searchBooksByTitle(String title){ - return null; + ArrayList books = new ArrayList<>(); + for(Book book : this.publicBooks){ + if(book.getTitle().equals(title)){ + books.add(book); + } + } + return books; } public ArrayList searchBooksByTitle(String title, int sortBy){ @@ -28,6 +37,7 @@ } public ArrayList searchBooksByAccount(String accountId){ + return null; } @@ -42,9 +52,5 @@ @Override public void bookChanged(Account account, Book book) { - } - - - }