Matrix with Objetcs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Matrix with Objetcs

Gabriel La Torre
Hi! this is the first time I use Smalltalk. I created a class called Celd and I wanted to create a class called Matrix which will be a 2D-array of Celd or a Matrix if you prefere.

Could someone help me with the code?

I tried this:

Object subclass: #Matrix
    instanceVariableNames: 'cells range'
    classVariableNames: ''
    poolDictionaries: ''
    category: 'fiuba-explorador'

initialize
    "Inicializa por defecto"
    cells := Celd new.
    range := 6


But when I try to add a Cell... I can't thank you very much in advance.

Gabriel

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Matrix with Objetcs

Herbert König
Hi Gabriel,


GLT> Hi! this is the first time I use Smalltalk. I created a

welcome to a brand new world!

GLT> class called Celd and I wanted to create a class called Matrix
GLT> which will be a 2D-array of Celd or a Matrix if you prefere.

There is a class Matrix already. And in older Squeaks (3.6) there was
Array2D class.

GLT> Could someone help me with the code?

We need more details.

GLT> I tried this:

GLT> Object subclass: #Matrix
GLT>     instanceVariableNames: 'cells range'
GLT>     classVariableNames: ''
GLT>     poolDictionaries: ''
GLT>     category: 'fiuba-explorador'

GLT> initialize
GLT>     "Inicializa por defecto"
GLT>     cells := Celd new.
GLT>     range := 6


GLT> But when I try to add a Cell... I can't thank you very much in advance.

Which code do you use? And what is the definition of Class Celd?

You need a Collection or one of it's subclasses to implement a matrix.


Cheers,

Herbert  

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners