Created
October 18, 2024 20:32
-
-
Save zehan12/bfe0eeb4b7881e4684ea618474580599 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Notification { | |
| constructor(service) { | |
| this.service = service; | |
| } | |
| notify(message) { | |
| this.service.send(message); | |
| } | |
| } | |
| class EmailService { | |
| send(message) { | |
| console.log(`Sending email: ${message}`); | |
| } | |
| } | |
| class SMSService { | |
| send(message) { | |
| console.log(`Sending SMS: ${message}`); | |
| } | |
| } | |
| const notification = new Notification(new SMSService()); | |
| notification.notify("Order shipped"); // Sending SMS: Order shipped |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment