Conteúdo do Curso
Java Data Structures
Java Data Structures
Challenge (ArrayList)
Let's Practice!
Your task is to implement a library management system in Java. A Book
class has already been created for you with all the fields, setters, and getters. You can familiarize yourself with it in the Book
class.
Also, a LibraryDemo
class has been created for you, which tests all the methods from the Library
class.
Create a class Library
that represents a collection of books. Use an ArrayList
to store instances of the Book
class.
Implement the following methods in the Library
class:
addBook(Book book)
: Adds a book to the library;removeBookById(int id)
: Removes a book from the library based on the unique identifier;findBooksByAuthor(String author)
: Returns a list of books by the specified author;findBooksPublishedAfterYear(int year)
: Returns a list of books published after the specified year;displayAllBooks()
: Displays information about all the books in the library on the screen.
After that, you need to go to the LibraryDemo
class and run it. It will test the correctness of the methods you implemented.
Learning how to work with GitHub assignments can be found here .
Instructions and tips on how to solve this task are outlined on GitHub.
If you're having trouble with solving and understanding the task, I suggest you think more carefully because programmers try to solve problems independently. It's the best way to learn.
But if you are stuck, you can see solutions for this task here. Don't forget to rewrite this solution for yourself and analyze everything to master this topic truly:
Obrigado pelo seu feedback!