Your name:
| k | k := 1. (k<10) ifTrue: [Transcript show: k printString. Transcript space. k := k+k].
| k | k := 1. (k<10) whileTrue: [Transcript show: k printString. Transcript space. k := k+k].
| k | k := 1. [k<10] ifTrue: [Transcript show: k printString. Transcript space. k := k+k].
| k | k := 1. [k<10] whileTrue: [Transcript show: k printString. Transcript space. k := k+k].
Transcript show: (1+4 sqrt*3) printString.
mapcar function in Lisp with the
collect: message to collections in Smalltalk. How are they
similar? How are they different?
| a | a := Array new: 3. a at: 1 put: 3.5. a at: 2 put: (a at: 1) + 4.2. (a at: 2) <= (a at: 1) ifTrue: [Transcript show: 'smaller'].Explain in detail what objects are created, what messages are sent to which objects, and how the control structure works.
PinballGame defines the following methods:
tiltMessage
^ 'TILT!! TILT!! TILT!!'
tilt
Transcript show: self tiltMessage.
FancyPinballGame defines the following methods:
tilt
super tilt.
SoundGenerator speak: 'call the police!!'.
tiltMessage
^ 'This is a highly sophisticated device. Don't mess with me!"
What happens when you send the message tilt to an instance of
PinballGame? To an instance of FancyPinballGame? (Suppose that
SoundGenerator is an object that generates spoken speech.)
The revised new method for Stack class was defined as follows:
Stack new is evaluated.
Finally you can answer "no" to the first question but still answer the second question. You won't get any extra credit but you will get a colorful dinosaur stamp on your quiz if your answer is correct.