File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inheritance Problem/ Replace String

 
Ron Ingram
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Working on my CS class assignment and have hit a road block...

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

Question Class (Parent)


FillInQuestion class


Tester


 
dennis deems
Ranch Hand
Posts: 808
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks... a simple override display() to include a new System.out.println(temp3) was all it took...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic