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

Summer 2001 Mini-Assignments

There will be a weekly "mini-assignment" in order to keep everyone's programming skills sharp. Perhaps also they suggest directions for further playing around in Squeak. It's important to practice in order to get proficient in any programming system, and practice is more fun if the topic is interesting and isn't going to be graded.

Mini-assignments are individual work. After the second one, they are due at the beginning of the class period.

(m1) Saturday, May 19

Write a method
in class Integer that generates a number seven times as large as the receiver, converts that number to a string, and then displays that number on Transcript. For example, executing "
11 showTimesSeven
" should result in 77 being shown on Transcript. Remember that
is the receiver of a message,
converts things into strings, and
is a message Transcript understands for displaying strings.

(m2) Thursday, May 24

Write a method
in class
that returns the larger of the number squared and 100 times the number. For example, "1 largerFunction" should return 100, and "500 largerFunction" should return 250000.

(m3) Thursday, May 31

Write a method
in class
that returns the smallest factor of the receiver that is greater than 1. It should try numbers from 2 up to the the number itself, and it should return the first tried number which divides the receiver evenly. You can test whether a number divides evenly by using \\, the remainder function, and seeing if the result is 0. "9 smallestFactor" should be 3, "11 smallestFactor" should be 11, and "221 smallestFactor" should be 13.

(m4) Thursday, June 7

A chunky number is a number whose smallest factor is at least 17. 17 is chunky, and 19 is chunky, but 99 isn't chunky at all–its smallest factor is a measly 3. Write a method
in class
which returns
if a number is chunky and
otherwise. Then, write a class method
in class
that prints the chunky numbers between 2 and 100 onto Transcript. You might want to use the
method you wrote for last week.

(m5) Thursday, June 14

Write a class method
in class
which returns a collection containing the first 100 chunky numbers which are greater than 0. You may use any kind of collection you wish.

(m6) Thursday, June 21

Examine the following methods in class StringHolder: #contents and #acceptContents:. Write some code that creates a StringHolder and opens three PluggableTextMorph's viewing the contents of the StringHolder. If the user modifies any of the PluggableTextMorph's and chooses "accept" (alt-s), then all of the other PluggableTextMorph's should be updated with the new value. To get this working you will need to slightly modify StringHolder; describe your change as well as submitting the workspace code.

(m7) Thursday, June 28

Create a class named
with one instance variable name
. Add the following methods to it:

For full credit, you must use a Model-View architecture. This means that you will need to add a call to changed: somewhere, so that the UI updates at the right time.

(m8) Thursday, July 5

Write a method
in class Collection which returns the second smallest element of the collection. Use #< to decide whether one element is smaller than another. Examples:

(m9) Thursday, July 12

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. Use any reasonable criteria you like for "a random color" (if in doubt, ask a TA or the instructor).

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.

(m10) Thursday, July 19

Write a method in class Collection called
, which sends #asString to all elements of a collection and then concatenates the results together into a long string that is returned. Transcript should not be involved. For example:

(m11) Thursday, July 26 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
so that when a new request is submitted in the top pane, the proper result is computed and displayed in the bottom pane.
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.

Solutions to previous assignments

Links to this Page