I have a class that makes car objects. It has two instance variables: Make and Color. I am having an issue calling this method within the workspace (noted below)
Class Method -Constructor
make: aMake color: aColor
"Creates a new car object, sets its instance variables by the arguments"
|car|
car := self new.
car setMake: aMake setColor: aColor. "accessor method below"
^car
Accessor Method
setMake: make setColor: color
"sets the instance variables"
Make := make.
Color := color.
Workspace (calling code)
|car|
car := Car make: 'toyota' color: 'red'
I get 'Message Not Understood' when calling this line. What is the issue here?
Everything looks alright. The likely gotcha would be that your "constructor" (which would more likely be called an "instance creation message" in Smalltalk) needs to be implemented on the class side, and you may have done so on the instance side. Conversely, your set... must be on the instance side. Which message is not understood (error details always help)? It should say in the debugger and that would help clarify.