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

Sum2000 Midterm Review: Drawing in Smalltalk

Don't miss this one.


a. myPen := Pen new.
myPen north.
myPen turn: 30.
myPen go: length.
myPen turn: 120.
myPen go: length.
myPen turn: 120.
myPen go: length.

b. a := Box new.
b := Box new.
c := Box new.
a position: (0 @ (a size)).
b position: (a size) @ (a size).
c position: ((a size)/2 asInteger) @ 0.

c. A new box will be created and it will rotate clockwise 12 degress at a time for 30 times until it gets back to the original position, since it will be rotating 360 degress total.




length _ 50.
f _ Form extent: 200@200.
myPen := Pen newOnForm: f.
myPen up.
myPen goto: 0@150.
myPen down.
myPen north.
myPen turn: 30.
myPen go: length.
myPen turn: 120.
myPen go: length.
myPen turn: 120.
myPen go: length.
f display.

This works a little better for part (a).




Link to this Page