Inheritance Problem/ Replace String

Add a class FillInQuestion to the question hierarchy of How To 10.1. An object of this class is constructed with a string that contains the answer, surrounded by _ _, for example, "The inventor of Java was _James Gosling_". The question should be displayed as

The inventor of Java was _____

So, I've managed to split the string and store the right answers correctly. Also, I've been able to conjoin the _ _ to make the blank. My problem is the tester (QuestionDemo) passes the question containing _James Gosling_ to the FillInQuestion constructor which automatically calls super (Question) and passes the argument. All of my logic to handle the string is after it passes it to the Question constructor.. I need to be able to split the string and then pass to the Question constructor... Not sure how

It looks to me as if everything you need done is already happening in the FillInQuestion constructor. It creates the masked String, but then it doesn't do anything with it. You could either assign it to the superclass's text field, or override the superclass display method.

Ron Ingram

Ranch Hand

Posts: 73

posted 6 years ago

Thanks... a simple override display() to include a new System.out.println(temp3) was all it took...