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.
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.
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.
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.
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.
addDisplayBoxOn: aCount
| itemView itemArea |
itemView := self makeDisplayBoxOn: aCount for: #value.
itemArea := self constraintFrame: 0 @ (1 / 2)
corner: 1/ 3 @ 1.
self addView: itemView in: itemArea.
addStepDisplayBoxOn: aCount
| itemView itemArea |
itemView := self makeDisplayBoxOn: aCount for: #step.
itemArea := self constraintFrame: 2/3 @ (1 / 2)
corner: 1@ 1.
self addView: itemView in: itemArea.
buildViewOn: aCount
self addDisplayBoxOn: aCount.
self addIncrementButtonOn: aCount.
self addDecrementButtonOn: aCount.
self addResetButtonOn: aCount.
self addStepDisplayBoxOn: aCount.
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.