Suppose we have the following class and interface. Develop an object adapter to implement the interface.
class EncodeDecode {
Key key;
public void setKey(Key key) {
// set the key. Used by encode as well as decode.
}
public Message encode(Message message) {
// encode the message using the key and return the encoded message.
}
public Message decode(Message message) {
// decode the message using the key and return the decoded message.
}
}
interface SecuredComm {
// encode the message using the given key and return the encoded message.
public Message encode(Message message, Key key);
// decode the message using the given key and return the decoded message.
public Message decode(Message message, Key key);
}