Six of the methods are identical to those implemented for Stopwatch and TextEditor. To save time, you can copy the methods into TimeLogger. This section provides the steps for copying classes to move methods between applications. If you have not yet defined Stopwatch or TextEditor, this section also provides the code for the methods.
You can copy methods between classes contained in one application. Provided the target class is visible, you can also copy methods between classes in different applications; it creates an extension of the target class.
To copy methods from Stopwatch, you must copy Stopwatch, move the new class to DevelopTimeLogger, and then copy the methods from the new class to TimeLogger. The steps to do this are as follows:
To copy Stopwatch and move the new class to DevelopTimeLogger
Moving methods from the new class to TimeLogger
The methods are moved to TimeLogger. timeElapsedDisplay and timeElapsedDisplay: go into the Getters & Setters category; startButtonMotions:clientData:callData: goes into Event Handlers; and calculateTime: goes into Operations. Finally, delete the new class (Stopwatch2).
By following steps similar to those listed above, you can copy from TextEditor the methods fileName and fileName:. Both methods go into the Getters & Setters category.
Instead of copying methods, you can implement them by adding the following code to the class TimeLogger:
Method fileName
fileName "Private - Answers the value of fileName." ^ fileName
Method fileName:
fileName: value "Private - Sets the value of fileName." fileName := value.
Method startButtonMotion:clientData:callData:
startButtonMotion: aButton clientData: aRowColumn callData: callData "Private - The user pressed the Start button. Displays the time elapsed." startTime := Time now. self timeElapsedDisplay setString: ' 00:00:00'. "9 spaces before the time."
Method timeElapsedDisplay
timeElapsedDisplay "Private - Answers the timeElapsedDisplay for the receiver." ^ timeElapsedDisplay.
Method timeElapsedDisplay:
timeElapsedDisplay: aTextWidget "Private - Sets the timeElapsedDisplay for the receiver." timeElapsedDisplay := aTextWidget.
Method calculateTime:
calculateTime: time "Private - Answers the time elapsed in a format that displays Hours:Minutes:Seconds." | answer | answer := WriteStream on: (String new: 8). time hours < 10 ifTrue: [answer nextPut: $0]. time hours printOn: answer. answer nextPut: $:. time minutes < 10 ifTrue: [answer nextPut: $0]. time minutes printOn: answer. answer nextPut: $:. time seconds < 10 ifTrue: [answer nextPut: $0]. time seconds printOn: answer. ^answer contents
After you implement all of the methods for TimeLogger, try opening an instance of the class using DevelopChooser or by evaluating:
TimeLogger new open
Finally, ensure that you create versions of the classes and release them to DevelopTimeLogger. To do this, from an Application Manager, select Version/Release All from the Classes menu.
Also, create a version of each application. (See Example: Creating an application version.) If you want team members to work on the applications, create a new edition of the application versions. (See Example: Creating an application edition.)