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

Sp2001 Midterm Review: Drawing in Smalltalk

Explain what the drawing code does:

a. |pen|
pen _ Pen new.
pen up;goto: 100@100;down.
pen turn:30; go:20; turn: 120; go: 20; turn: 120; go: 20.

b. |boxA boxB boxC|
boxA _ Box new.
boxA move: 50@0 "Moves the box 50 pixels to the right"
boxB _ Box new.
boxB move: 25@50. "Moves box as base for A "
boxC _ Box new.
boxC move: 75@50. "Moves box to complete pyramid base"

c. It will turn the box 360 degrees back to it's original position, but the user won't be able to see anything because it happens to quick. So it will seem like nothing was done to the box.

Bharath Hemachandran
The answer given for part b. I think is wrong.
I evaluated the code and it looked nothing like what it should.
I thought it was supposed to be a box inside a box inside a box.

My implementation:
p1 _ Box new.
p1 move: 70@200. "Move to coord."
p2 _ Box new.
p2 grow: 20.
p2 move: 60@210. "2nd box, larger than first, put around p1"
p3 _ Box new.
p3 grow: 40.
p3 move: 50@220. "3rd larger still, put around other 2"


Link to this Page