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

M9 - M11


Problem Description:

Write some workspace code that, if executed in a morphic project, will change the color of the current world morph to be a random color. The current world morph is stored in the global variable World.

There are two steps to this problem. Solve them one at a time! First, figure out a way to choose a random color. Second, figure out a way to change World's color to the color that was chosen.


World color: Color random

This does exclude certain posssibilities, so if you want a greater possible range, something like this might be more to your tastes...

ourColor _ Random new.
World color: (Color r: (ourColor next) g: (ourColor next) b: (ourColor next))


Problem Description:

Write a method in class Collection called concatenatedStrings, which sends #asString to all elements of a collection and then concatenates the results together.



^(self asArray do: [ :index | index asString ]) asStringWithCr copyWithout: (Character cr)

unknown person X:

s := ''.
self do: [:i | s := s, (i asString)].

That's the way a number of people chose to do it, as I recall. I happen to like not having many temporary variables, not that it's necessarily a worse or better way of solving the problem. Shaggz

unknown person X:

temp vars r0x d4 c4sb4h.

Yes they certainly do! Shaggz


Problem Description; contains an incomplete class that can be used to evaluate expressions. File it in and execute "Evaluator openInMorphic" in a
Morphic project to see what is there. You should be able to type an expression into the top pane of the window, press alt-s, and see the
result in the bottom pane... except that it doesn't work yet.

Currently, the GUI is set up, but the model doesn't actually recompute the result when a new request is submitted. Implement
updateResult so that when a new request is submitted in the top pane, the proper result is computed and displayed in the bottom pane.
updateRequest is already called whenever the request changes, but currently it does nothing.

In the interest of simplicity, you don't need to implement any error handling.



result _ Compiler evaluate: request.
self changed: #resultAsString

Link to this Page