On 1 avr. 2014, at 16:50, Roelof Wobben <r.wob...@home.nl> wrote:

> Nicolai Hess schreef op 1-4-2014 16:44:
>> 2014-04-01 16:21 GMT+02:00 Roelof Wobben <r.wob...@home.nl>:
>> Camille Teruel schreef op 1-4-2014 15:08:
>> 
>> On 1 avr. 2014, at 14:52, Roelof Wobben <r.wob...@home.nl> wrote:
>> 
>> Hello,
>> Hello,
>> 
>> Im on this page now: http://squeak.preeminent.org/tut2007/html/017.html
>> 
>> I do not understand one thing.
>> 
>> Where do I put the initialize "script"
>> #initialize is not a script, it's a method. When an object is instantiated 
>> (for ex with: MyObject new) #initialize is automatically sent to it.
>> This is the place to put your newly created object in a correct initial 
>> state.
>> In your class, you just define a protocol named for example "initialization" 
>> where you put all the initialization-related methods.
>> Note that protocols have no meaning, i.e. they don't change how your objects 
>> behave, they're just here to help you classify
>> the methods of a class by concerns.
>> So the tutorial tell you to create two methods: #initialize that is 
>> automatically called after an object has been instantiated and 
>> #initializeActiveSegments where you
>> put some other initialization logic, that's all.
>> 
>> When I put it on the initializeActiveSegments then initialize get not found.
>> Sorry, I don't understand.
>> 
>> Or must I make a seperate protocol named ActiveSegments for it.
>> No use the same protocol "initialization" or "initialize-release" or 
>> whatever.
>> 
>> 
>> Oke,
>> 
>> I changed it so I have this :
>> 
>> Laser-Game-Model
>> with as classes:
>>   - BlankCell
>>   - Grid
>>   - MirrorCell
>>   -TargetCell
>> 
>> 
>> BlankCell has the following protocols:
>> - initializing-release
>> - testing
>> 
>> Initializing - release contains the following  methods:
>>  - initialize
>>  - initializeActiveSegments
>> 
>> testing contains the following methods:
>> isOn
>> isOff
>> 
>> but when I run the test-runner I see this : MessageNotUnderstood : BlankCell 
>> >> activeSegments.
>> 
>> Roelof
>> 
>> 
>> 
>> 
>> 
>> Then you missed the last step on 
>> http://squeak.preeminent.org/tut2007/html/016.html
>> Select "create instance var accessors" from the second popup menu.  
>> 
>> 
>> 
> 
> 
> I also did.
> See this : 
> 
> Object subclass: #BlankCell
>     instanceVariableNames: 'activeSegments'
>     classVariableNames: ''
>     category: 'Laser-Game-Model'

This message just serve as a class definition, it basically says "I want a 
class named BlankCell, subclass of Object, with one instance variable named 
activeSegments, in the category Laser-Game-Model". 
But, it says nothing about BlankCell methods.
So as Nicolai pointed out, you forgot to do the last step of page 16. It will 
create two methods for accessing the instance variable activeSegments:

First an accessor method:
BlankCell>>activeSegments
        ^ activeSegments

And a mutator (you should rename the argument to better convey the intent)
BlankCell>>activeSegments: anObject
        activeSegments := anObject

> 
> Roelof
> 

Reply via email to