CEN206 Object-Oriented Programming
D5. Using the Refactored Service
public class NotificationDemo {
public static void main(String[] args) {
NotificationService service = new NotificationService();
Map<String, String> params = new HashMap<>();
params.put("name", "Alice");
params.put("orderId", "ORD-456");
params.put("total", "149.99");
NotificationRequest emailReq = new NotificationRequest(
"email", "alice@example.com",
"Order Confirmed",
"Thank you for your purchase!",
false, "order_confirmation", params
);
service.send(emailReq);
System.out.println("---");
NotificationRequest smsReq = new NotificationRequest(
"sms", "+1234567890",
"Alert", "Server is down!",
true, null, null
);
service.send(smsReq);
System.out.println("---");
NotificationRequest slackReq = new NotificationRequest(
"slack", "#engineering",
"Deploy Complete",
"Version 2.5.0 deployed to production.",
false, null, null
);
service.send(slackReq);
}
}