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

bookChallenge: Build a Mini Library System

Aufgabe

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.

Lösung

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 3. Kapitel 4
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

close

bookChallenge: Build a Mini Library System

Swipe um das Menü anzuzeigen

Aufgabe

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.

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 3. Kapitel 4
single

single

some-alt