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 | Introduksjon til Python OOP
Practice
Projects
Quizzes & Challenges
Quizer
Challenges
/
Objektorientert Programmering i Python

bookChallenge: Creating Notification System Blueprint

Oppgave

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

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 14
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

close

bookChallenge: Creating Notification System Blueprint

Sveip for å vise menyen

Oppgave

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 desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 14
single

single

some-alt