
We saw in previous lessons some general Classes of the Smalltalk language, included in the group of Classes available for the Croquet developer (the Croquet API - Application Programming Interface).
But where can you find the other Classes available?
Open the "Scratch" window. In the "Tools" of the "Green window", drag the "Browser":
Try to find : SimpleDemoMorph-Worlds in the first left division. Click. In the second division will appear: SimpleDemoWorld. This is the name of one of the MANY Classes available at the Croquet API. Clicking it, appears some other divisions.
TIP: The "official" Croquet API is updated when you click the button "Install updates" in the "First Steps" window. Do it each week.
How to create a new Class?
First you need to know that all the new Classes are subclasses of the super-superClass: Object.
Having any Class appearing, type over its definition, the definition of the new:
We need to create an "initialize" method for our Class Cat.
An "initialize" can have a parameter. We will set a value for this parameter when creating a new object of the Class. Something like:
myCat := Cat new initialize:'Darling'.
You need to do an "accept" to "save" (a "little save") your definitions.
We will create another method: say, that prints the name of the cat and a string.
TIP: One of the usual mistakes of Croquet programers is to forget to do the "accepts".
To create a "program" we use the windows "Workspace" and "Transcript" like we did in the exercices of the basic Smalltalk Classes.
To mantain our new Class beeing a Class of the Croquet (our Croquet now ) API, open the "World window" and click: save.
This is a "big save".
TIP: If you like, you can create a new "image" of Croquet, having your addiction, mantaining the original not changed. Select: save as.... But each new "version" uses 27 MB!
PREVIOUS LESSON NEXT LESSON T. CONTENTS HOMEPAGE
