Challenge: Library Management System
Oppgave
Swipe to start coding
Your task is to complete the Library class by filling in the missing parts:
-
addBook(Book book)method:- Add the given book to the
bookslist.
- Add the given book to the
-
findBooksByAuthor(String author)method:- Iterate over all
Bookobjects in thebookslist. - For each book, check if its author matches the given
author. - If it matches, add the book to a temporary list called
result. - After the loop, return the
resultlist.
- Iterate over all
-
displayAllBooks()method:- Iterate over all
Bookobjects in thebookslist. - For each book, print its ID, title, and author in a readable format.
- Iterate over all
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 3
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Fantastisk!
Completion rate forbedret til 6.25
Challenge: Library Management System
Sveip for å vise menyen
Oppgave
Swipe to start coding
Your task is to complete the Library class by filling in the missing parts:
-
addBook(Book book)method:- Add the given book to the
bookslist.
- Add the given book to the
-
findBooksByAuthor(String author)method:- Iterate over all
Bookobjects in thebookslist. - For each book, check if its author matches the given
author. - If it matches, add the book to a temporary list called
result. - After the loop, return the
resultlist.
- Iterate over all
-
displayAllBooks()method:- Iterate over all
Bookobjects in thebookslist. - For each book, print its ID, title, and author in a readable format.
- Iterate over all
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 3
single