Challenge: Creating Notification System Blueprint
Tâche
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.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 1. Chapitre 14
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Génial!
Completion taux amélioré à 3.85
Challenge: Creating Notification System Blueprint
Glissez pour afficher le menu
Tâche
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.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 1. Chapitre 14
single