Hi everybody! I've just joined the community:) and have a question How to write the method count: such that, when invoked on an instance of Counter, instance variable is set to the argument given to the message? *so thatCounter new count: 7* *would set the value of a new Counter instance to 7* (It is a little exercise from http://rmod-pharo-mooc.lille.inria.fr/MOOC/Exercises/Exo-Counter.pdf) Best wishes, Kateryna
On Sat, Dec 10, 2016 at 1:39 AM, Kateryna Aloshkina <aloshkina@ucu.edu.ua> wrote:
Hi everybody!
I've just joined the community:) and have a question How to write the method count: such that, when invoked on an instance of Counter, instance variable is set to the argument given to the message? so that Counter new count: 7 would set the value of a new Counter instance to 7 (It is a little exercise from http://rmod-pharo-mooc.lille.inria.fr/MOOC/Exercises/Exo-Counter.pdf)
Best wishes, Kateryna
Welcome Kateryna, I hope you are having fun and Pharo changes the way you think about programming. Referring to Figure 1.2, assuming you've already created the class, first make sure you are on the instance-side rather than the class-side of the class such that the class definition in the bottom (code) pane looks just like Figure 1.2. Click the <Class> button to toggle which side you look at. Now in the third (protocols) pane on "no messages" and you will get a method template in the code pane Change... messageSelectorAndArgumentNames to... count: then change.... statements to an assignment to the instance variable. and <Accept> the the code to save & compile the method. cheers -ben
Hi everybody!
I've just joined the community:) and have a question How to write the method count: such that, when invoked on an instance of Counter, instance variable is set to the argument given to the message? so that Counter new count: 7 would set the value of a new Counter instance to 7 (It is a little exercise from http://rmod-pharo-mooc.lille.inria.fr/MOOC/Exercises/Exo-Counter.pdf)
did you check the videos? because this is shown count: anInteger counter := anInteger
Best wishes, Kateryna
-- Using Opera's mail client: http://www.opera.com/mail/
participants (3)
-
Ben Coman -
Kateryna Aloshkina -
stepharong