I have two classes, "Quote" (superclass) and "RealQuote" (subclass). "Quote" has a following features:
// Attribute
private String sentence;
// Constructor
public Quote(String aSentence) {
sentence(aSentence);
// Accessors
public String sentence() {
return sentence;
}
public void sentence(String newSentence) {
sentence = newSentence;
}
I need to utilize the constructor in Quote to create a constructor in subclass RealQuote that has attributes: String sentence, String speaker.
As the attribute for the speaker is not included in the superclass, I wonder how can I utilize it to create a constructor with different number of parameters? I assume I will have to call the existing constructor somewhere, but how can I add more parameters to it in the subclass?
I tried this:
public RealQuote(String aSentence, String aSpeaker) {
super();
speaker(aSpeaker);
}
However, obviously it does not work, because the called superclass constructor does not have enough arguments, but I don't know what to add there or even if anything I have this far is correct.