b fish wrote: Using interfaces are totally new to me, so I am not quite sure the best way to set one up. Also I am struggling to figure out how to then populate a MatrixEntity object with information that the user puts in from the consul, i.e. the best way to plug in each integer value to the multi dimensional array.
~ Mansukh
~ Mansukh
It would probably be better design to have a Matrix interface. You can then create all sorts of classes which implement that interface and use them all under the generic title “Matrix”.Mansukhdeep Thind wrote:Why do you need to have a separate interface at all?
There is no such thing as a 2D array.You could simply create the 2D array . . .
Campbell Ritchie wrote:
There is no such thing as a 2D array.Mansukhdeep Thind wrote: You could simply create the 2D array . . .
~ Mansukh
Campbell Ritchie wrote:
It would probably be better design to have a Matrix interface. You can then create all sorts of classes which implement that interface and use them all under the generic title “Matrix”.Mansukhdeep Thind wrote:Why do you need to have a separate interface at all?
There is no such thing as a 2D array.You could simply create the 2D array . . .
Beware: MatrixInterface is a bad name for the interface. Simply call it Matrix. It would require other methods, eg add() subtract() mutiply(), etc. I can’t remember much matrix arithmetic. Remember that you cannot add methods to the interface once you have implemented it, so make sure it has all the requisite methods before you let it loose on an unsuspecting world.
Paul Clapham wrote:
As for the error message you're asking about -- yes, your createSingleMatrix() method should be a static method. It shouldn't be a method of the Matrix type because it isn't the job of a Matrix to produce another Matrix. I also don't understand why you have two methods called createSingleMatrix and createSecondMatrix when they do exactly the same thing. Why not just a createMatrix(int, int) method?
b fish wrote:As for the method creating matrices, if I create a single method, how will I make the second matrix for the addition, subtraction and multiplication operations?
I guess I am just looking for a good way to create two different MatrixEntity objects so I can them use them my operations on them.
Paul Clapham wrote:
b fish wrote:As for the method creating matrices, if I create a single method, how will I make the second matrix for the addition, subtraction and multiplication operations?
I guess I am just looking for a good way to create two different MatrixEntity objects so I can them use them my operations on them.
You call the single method twice.
b fish wrote:
Paul Clapham wrote:
b fish wrote:As for the method creating matrices, if I create a single method, how will I make the second matrix for the addition, subtraction and multiplication operations?
I guess I am just looking for a good way to create two different MatrixEntity objects so I can them use them my operations on them.
You call the single method twice.
won't that create two matrices with the name "Matrix 1" ?
Life is full of choices. Sometimes you make the good ones, and sometimes you have to kill all the witnesses.
Consider Paul's rocket mass heater. |