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

Adding an instance creation method

Previous pageReturn to chapter overviewNext page

Now we need a class method to use when creating a Question instance.

Important: Make sure you set the Class Browser into Class mode before adding this method otherwise it will override the one you have just created on the instance side.

text: aString yes: yesPath no: noPath

       "Answer an instance of the receiver (a Question) having aString as it's text and

       leading to the nodes at yesPath and noPath as the result of those answers to its



       ^self new text: aString yes: yesPath no: noPath