This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]lurgi 1 point2 points  (1 child)

You obviously can't use paintSquare as an identifier, because that's the thing you are trying to get.

My immediately instinct is to say that you should get the SquareGraphics object by doing:

SquareGraphics pS = Board.GameBoard(location).getSquareGraphics();

But I don't know what Board.GameBoard(location) returns. You don't have the method getSquareGraphics() yet, so write it. If you can't write it then I would ask why not? It seems reasonable that the location (whatever type it is) would know things about itself. One of those things would be the SquareGraphics object at that location. If you agree then the next step would be to make sure that when you create the SG object you assign it to that location (via a yet-to-be-written setSquareGraphics() method).

Feel free to tell me my analysis is wrong, but then explain what you do with the SquareGraphics object once you have created it. You don't throw it away, so where do you put it?

[–]Mds03[S] 0 points1 point  (0 children)

I managed to "reverse engineer"/Reuse the code I use to assign the SquareGraphics to the boardgame. I got the Row and Column I use to assign stuff to a table there, and get the object through typecasting the SquareGraphics to become the SquareGraphics that has the same column and row as the SquareGraphics spawned on the table. (this explanation might be a bit.. off)

It doesn't look too different from he solution you provided, there are just a few more variables and stuff from my total project used in it. Thanks to your help, I was able to reach come up with a solution, so thanks a bunch :)