In this task, you will enhance a basic library management system in Kotlin by implementing several functions in the LibraryService class.
This system allows users to add books to their libraries and search for them by title, author, or genre. The LibraryService class already contains skeleton methods you must fill out.
Additionally, you are provided with two data classes: Book and Author.
- A
Bookcontains a title, list of authors, publication date, genre, and ISBN fields. - An
Authordata class has only one field, name.
-
Create an
Authorclass with a single fieldnameof typeString. -
Create a
Bookclass with the fields described below. Please put them in the order as follows:-
titleof typeString; -
authorsof typeList<Author>; -
publicationYearof typeInt; -
genreof typeString; -
isbnof typeString;
-
-
Implement the
addBook(book: Book)method to add a new book to the library.
💡Use some collection here. Book duplicates are allowed.
-
Implement the
searchByTitle(title: String): List<Book>method to return a list of books that contain the given title. The search should be case-insensitive. -
Implement the
searchByAuthor(authorName: String): List<Book>method to return a list of books written by authors whose names contain the given string. This search should also be case-insensitive. -
Implement the
searchByGenre(genre: String): List<Book>method to return a list of books that match the given genre exactly, with case-insensitivity.