Challenge: Build a Mini Library System
Tarefa
Swipe to start coding
Create a class named Library with a method called borrowBook. This method should:
- Accept the name of a book as a parameter.
- Throw an Exception with a clear message if the requested book is not in the library's list of books.
- If the book is available, remove it from the list (no need to return anything).
When calling the borrowBook method, catch the exception and print its message using echo.
Follow these steps:
- Implement the borrowBook method inside the Library class.
- In the provided code, try to borrow the book
'The Great Gatsby'. - Catch any exception and print its message.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 3. Capítulo 4
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Incrível!
Completion taxa melhorada para 6.67
Challenge: Build a Mini Library System
Deslize para mostrar o menu
Tarefa
Swipe to start coding
Create a class named Library with a method called borrowBook. This method should:
- Accept the name of a book as a parameter.
- Throw an Exception with a clear message if the requested book is not in the library's list of books.
- If the book is available, remove it from the list (no need to return anything).
When calling the borrowBook method, catch the exception and print its message using echo.
Follow these steps:
- Implement the borrowBook method inside the Library class.
- In the provided code, try to borrow the book
'The Great Gatsby'. - Catch any exception and print its message.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 3. Capítulo 4
single