Navigation:  Tutorials > Beginners Guide to Smalltalk > Programming in Smalltalk > Creating the Question class >

Printing and displaying a Question

Previous pageReturn to chapter overviewNext page

The following methods allow for a Question to be represented as text from the point of view of an end-user and developer respectively. You can use the category suggestion feature of the browser to place these methods into their correct categories.

Important: Place the browser back into Instance mode before adding these methods.

displayOn: aStream

       "Answer the name of the receiver as a user should see it. For this

       we append a question mark."


       aStream nextPutAll: self text; nextPutAll: ' ?'.


printOn: aStream

       "Answer the name of the receiver as a developer would wish

       to see it."


       super printOn: aStream.

       aStream nextPut: $(.

       self displayOn: aStream.

       aStream nextPut: $).