CS 2390 - Lab # 2: The Count in SmallTalk

What We're Gonna Do:

In this lab, we are going to add create a subclass of IntegerCount, IntegerStepCount, which will take a step value and increment and decrement by that step value. In addition, we are going to modify the user interface so that another dis play window is created, which displays what the current step value is.

Most of the source codes are already given. However, you will need to do some modifications.

Step One: Setting up Environment:

It is not a good idea for you to put all your labs and projects in your one directory. So you'd better make a directory to work in for this lab ( mkdir lab2 ) and then change directory into the one you just created (cd lab2). From there, execute VisualWorks Smalltalk by typing visual &.

>From the FILE menu, choose Settings and enter in the following line under Source:
/remote/sun4m/sun4m/lib/visual/image/visual.sou

If this does not work, try:
/remote/sun4c/sun4c/lib/visual/image/visual.sou

You should do this setting every time when you run VisualWorks Smalltalk in Rich-Sun lab.

Step Two: Filing in Source Code:

In this lab, you will need the following classes: You can get the code for those classes by clicking on it, and then use Save As from File menu of Netscape to get copies of your own. Please make sure that those files are saved in your directory for this course.

Now, in VisualWorks window, press the left most button (which is blue and has the icon of a file cabinet), to pop up a File List window. At the top row of this window, type in *.st and return. Three files which were just down loaded by you should appear below. Click at UI.st to highlight it, and use the middle mouse button to select file in. After you filled in this code, do the left two files in same way.

To verify if those codes were filed in correctly you can open a System Browser now. The last three categories in the category list should be Model Views, Count Views, and Counts.

If you don't see these catagories in the System Browser, click the middle mouse button in the upper left hand window of the System Browser, and select the Update option.

You can also use the Find Class option (also from the Class Category pane), to locate the Count class.

Step Three: Running The Count Classes:

In the Workspace, type in

CountViewContainer new openOn: (IntegerCount new).

Highlight it and "do it." A small integer count will appear. You can do increment, decrement, and reset by click on those three buttons.

Step Four: Creating the IntegerStepCount Class:

Create this class as a subclass of the IntegerCount class,with one additional instance variable called step. Also define two additional methods: step and step: . Where, step returns the current value of step, and step: takes a value, and sets the step value to it.

Also remember that as there will be a view on the step value, we need to let it know when the step value has changed. This can be done by adding the line:

self changed: #step.

at the end of the step: method.

We also need to reimplement the increment and decrement methods in this class so they count by step value, instead of by 1.

Step Five: Modifying the User Interface:

We will do this by creating a subclass of CountViewContainer , called StepCountViewContainer . After creating the StepCountViewContainer subclass, we need to add three methods to this class to make it useful:

Step Six: Running the code:

In the transcript window, type in:

| aStepCount |
aStepCount := IntegerStepCount new.
aStepCount step: 23.
StepCountViewContainer new openOn: aStepCount.

A window should pop up with two display boxes: One with the current value and the other with the current step value.

Step Seven: Turning in the code

Go to the system Browser and select the Counts category. Choose the middle-button menu item File Out and type a file name (or default Counts.st) when prompted. Do same thing also on Count Views category. Send the file to your TA by using the relevant command

Attention:

(1) mail all your codes together instead of in several times;
(2) add a subject to the mail.
(3) Do not mail the UI.st file to the TA.
(4) Do not edit the smalltalk files !

2390a:
cat
counts.st countviews.st.st | mail -s "LAB#2- YOUR NAME" jy17@prism

2390b:
cat
counts.st countviews.st.st | mail -s "LAB#2- YOUR NAME" tee@cc.gatech.edu

2390c:
cat
counts.st countviews.st.st | mail -s "LAB#2- YOUR NAME" fn9@prism.gatech.edu


These are required for all the lab and project hand-ins in the future.

That's all for this lab. Quit from VisualWorks before you logout.