Question
I want to apply the adapter design pattern. There is a system that delivers notifications to its users. The Notification interface is as below: public
I want to apply the adapter design pattern.
There is a system that delivers notifications to its users. The Notification interface is as below:
public interface Notification {
void setRecipient(User recipient);
void setSender(User sender);
void setMessage(String message);
String getMessage();
}
And the User interface looks like the following:
public interface User {
String getName();
String getMobileNumber();
Notification getPreferredContact();
}
This code was written to implement the Notification interface for in-system messages using a class InternalNotification. They would like to expand the system to SMS notifications and purchased code that will send SMS messages. That interface for an SMS message is :
public interface SmsMessage {
public void setSender(String phoneNumber);
public void setRecipient(String phoneNumber);
public void setMessageBody(byte[] data);
public byte[] getMessageBody();
}
I want to implement a class SmsToNotificationAdapter that lets the system use SMS messages to notify its users.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started