Adding a hasChildren attribute
Let's add a hasChildren attribute to the Card part and use it to keep the container aware of the structure of our tree. Open the Public Interface Editor view for the Card part. Add the hasChildren attribute with an Attribute data type of Boolean. Select Generate Default Scripts from the File menu. In the Generate Default Scripts window select the hasChildren instance variable and its get and set selectors. Select the Generate selected push button to create the needed scripts.
Switch to the Script Editor view of the Card part and change the hasChildren get selector as follows:
hasChildren
"Return the value of hasChildren."
hasChildren == nil ifTrue: self hasChildren: false].
^hasChildren
Because you make false the default attribute value, no other script changes are needed for this part. Save the Card part.
Last modified date: 01/29/2015