Prompting for a new Question
And, almost finally, we need a method to prompt for a new Question object.
Question class>>promptToDistinguish: anOldAnimal from: aNewAnimal
"Answers an instance of the receiver (a Question) that will distinguish between
anOldAnimal and aNewAnimal. The question should be phrased such that the
answer is 'yes' for aNewAnimal"
| questionText |
[questionText isNil or: [questionText isEmpty]] whileTrue: [
questionText := Prompter prompt: ('Now, please enter a question that will answer Yes for ',
' and No for ',
caption: 'Now, so I can learn about ', aNewAnimal displayString ].
^self text: questionText yes: aNewAnimal no: anOldAnimal
Once again we have to use a Prompter and check to see that a valid response is received from the player before creating the new instance.