Skip to content

Commit

Permalink
feat: Implement method to filter books by genre and make test pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
VishwajeetVT committed Sep 4, 2024
1 parent c0a11cc commit 6d54265
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ public Optional<Book> findBookByTitle(String title) {
.filter(book -> book.getTitle().equalsIgnoreCase(title))
.findFirst();
}

public List<Book> filterBooksByGenre(String genre) {
return books.stream()
.filter(book -> book.getGenre().equalsIgnoreCase(genre))
.toList();
}
}

0 comments on commit 6d54265

Please sign in to comment.