getBook method
Fetches a specific book by its number from a collection.
Implementation
Future<Book> getBook(Collection collection, int bookNumber) async {
List<Book> books = await getBooks(collection);
return books.firstWhere(
(book) => book.bookNumber == bookNumber.toString(),
orElse: () => throw Exception(
'Book number $bookNumber not found in $collection.',
),
);
}