Fix messages

Report a typo

You are given a class hierarchy of messages. Unfortunately, it's incorrect.

interface Message {

    protected String sender;
    protected String dest;

    String getSender();
    String getDestination();
    String getText();
}

abstract class BaseMessage extends Message {
    
    public BaseMessage(String sn, String dst) {
        sender = sn;
        dest = dst;
    }

    @Override
    public String getSender() {
        return sender;
    }
}

class CipherMessage extends BaseMessage {

    protected String text;

    public CipherMessage(String sender, String destination, String text) {
        super(sender, destination);
        this.text = CryptoUtils.encrypt(text); // just an example, suppose it's OK
    }

    @Override
    public String getText() {
        return text;
    }
}

What should be done to correct the code? Choose only necessary steps.

Select one or more options from the list
___

Create a free account to access the full topic