Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Creating Notification System Blueprint | Introduktion til Python OOP
Objektorienteret Programmering i Python

bookChallenge: Creating Notification System Blueprint

Opgave

Swipe to start coding

Design a notification system using abstract classes to practice inheritance and polymorphism in Python.

  • Create an abstract base class named Notifier with an abstract method send(message).
  • Implement two subclasses: EmailNotifier and SMSNotifier. Each should implement the send method and return a string indicating how the notification was sent (for example, "Email sent: ..." or "SMS sent: ...").
  • Write a function notify_user(notifier, message) that calls the notifier's send method and returns its result.
  • Create one object of each notifier and use notify_user to test both, passing a sample message to each.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 14
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

close

bookChallenge: Creating Notification System Blueprint

Stryg for at vise menuen

Opgave

Swipe to start coding

Design a notification system using abstract classes to practice inheritance and polymorphism in Python.

  • Create an abstract base class named Notifier with an abstract method send(message).
  • Implement two subclasses: EmailNotifier and SMSNotifier. Each should implement the send method and return a string indicating how the notification was sent (for example, "Email sent: ..." or "SMS sent: ...").
  • Write a function notify_user(notifier, message) that calls the notifier's send method and returns its result.
  • Create one object of each notifier and use notify_user to test both, passing a sample message to each.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 14
single

single

some-alt