Skip to main content

Practice ยท 2 of 2

Interface-driven notifications

Inside Solution, write interface Notifier { String send(String msg); } plus two implementations: static class EmailNotifier implements Notifier returns "EMAIL: " + msg, and static class SmsNotifier returns "SMS: " + msg. Implement static String broadcast(Notifier n, String msg) that dispatches through the interface.

Difficulty: beginner

Back to lesson: Practice: Practice: Designing with Polymorphism