View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Teddy's CoWeb Assignment 2

Tracing Code (1 point)

1 + 2 x 3 4 factorial MessageNotUnderstood Error
a := #(1 2 3 4 5) #(1 2 3 4 5)
a select: [:i | i odd] #(1 3 5)
b := a #(1 2 3 4 5)
a := a reversed #(5 4 3 2 1)
b collect: [:i | i x i] #(1 4 9 16 25)
a perform: #at: withArguments: #(4) 2

Message Passing (1 point)

while loop
[aBooleanTest] whileTrue: ["do stuff"].
Object: [aBooleanTest]
Message: whileTrue:
Arguments: ["do stuff"]

for loop
1 to: 20 do: ["do stuff"].
Object: 1
Message: to: & do:
Arguments: 20 & ["do stuff"]

if/then/else loop
[aBooleanTest] ifTrue: ["do stuff"] ifFalse: ["do stuff"].
Object: [aBooleanTest]
Message: ifTrue: & ifFalse:
Arguments: ["do stuff"]

Link to this Page