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

Discussion 4 - Arwa Tyebkhan

Question from Midterm Review - Fall 2002

WRITE SMALLTALK CODE:

Write workspace code (something I can select and say DoIt in the workspace) to draw the below figure. Don't worry about exact sizes–just draw two rectangles with the text inside. (To remind you, Pens know how to up, down, go:, turn:, and north:. Strings know how to displayAt: a given point.)

Answer:

pen _ Pen new.
pen color: Color black.

pen up.
pen goto:200@250.
pen turn:0.

pen down.
pen go:60; turn:90; go:90; turn:90; go:60; turn:90; go:90.

pen up.
pen goto: 280@240.
pen turn:0.

pen down.
pen go:70; turn:90; go:40; turn:90; go:70; turn:90; go:40.

str _ String new.
str _ 'CS2340'.
str displayAt: 230@210.

Links to this Page