Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Challenge: Build a Mini Library System | Organizing and Applying OOP in PHP
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Object-Oriented PHP

bookChallenge: Build a Mini Library System

Taak

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.

Oplossing

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 4
single

single

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

Suggested prompts:

Can you explain this in simpler terms?

What are some examples related to this topic?

Where can I learn more about this?

close

bookChallenge: Build a Mini Library System

Veeg om het menu te tonen

Taak

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.

Oplossing

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 4
single

single

some-alt