Author | Message |
---|---|
erami201
Posts: 1
|
Posted 17:30 Sep 27, 2018 |
The instructions state that we need a constructor which takes the question text as a parameter. Since the question text is from the parent class I used the super key word to refer to it but, I get an error stating that I need to change the visibility to protected. What I currently have is super.questionText = questionText; . I originally tried super(questionText,questionAnswer); but, I realized that we only need the question text from the parent. I've taken a look at the geometric object example but, I can't seem to solve the error. The constructor should also initialize the ArrayList to be an empty ArrayList and that is working just fine. Could it possibly be the way I have written the constructor's parameters?
|
rgallegos
Posts: 29
|
Posted 18:26 Sep 27, 2018 |
Have you tried using the parents getters/setters? When you create a MCQuestion object it has to create an instance of the Question class first. You have the question part given and you can pass that in while leaving the answer blank until you need to set the answer. |
kknaur
Posts: 540
|
Posted 20:15 Sep 27, 2018 |
This is correct. You have to remember that if a data field from the parent is private, then you cannot access it using super.dataFieldName. If you want to create a constructor which accepts only the question you could do this as well. Otherwise your only other option would be to use the public setter for that data field. |