Reputation: 93
I have a interface Appendable
in which I have a method appendTo(Appendable obj)
. Classes TextMessage
and EncMessage
extend class Message
, which implements Appendable
.In TextMessage
I have to implement method appendTo(Appendable obj)
so that if obj
is an instance of TextMessage
the method is supposed to change its data members. But I can't access TextMessage
set methods.So my question is how can I access and use them?
Upvotes: 0
Views: 46
Reputation: 393821
You could implement appendTo of TextMessage like this :
void appendTo (Appendable obj) {
if (obj instanceof TextMessage) {
TextMessage msg = (TextMessage) obj;
msg.setXXX (...);
...
}
}
I had to make some assumptions without actually seeing your code.
Upvotes: 2