This site requires JavaScript, please enable it in your browser!
Greenfoot back
Loled85
Loled85 wrote ...

2015/12/31

How to create an Array?

Loled85 Loled85

2015/12/31

#
Hey guys, I wanted to create an Array that saves the coordinates of the corners in a 3x3 World (which should be (0|0),(0|2),(2|0),(2|2)), to create randomly four Objects of the same class on this coordinates, as long as the randomly chosen spot is not already filled... So how do I create this array?
danpost danpost

2015/12/31

#
Something seems off, here. You said a 3x3 world (which would be 9 locations within the world) but you said 4 objects (for which a 2x2 world would be sufficient); or are you only using the four corner areas of the 3x3 world (middle row and column empty)?. What is the 'super' call in your World subclass constructor?
Loled85 Loled85

2015/12/31

#
Super(3,3,60) And yes, like I said I just want the corners which should be four and be the locations 0|0; 0|2; 2|0; 2|2. I want this locations to be saved in an Array so I can just check whether one location is filled or not.
Loled85 Loled85

2015/12/31

#
Yeah, forget what I just wrote. I just wrote a whole new programm, with just more Subclasses for the mentioned Object. That fixed it already, still thank you for your help!
danpost danpost

2015/12/31

#
I really do not see a need for the array at all -- especially if its only purpose was to ensure a corner was not taken before placing an object there. Maybe if you explained a bit more of what you are trying to accomplish, something can be forthcoming. Information like when these object are to be placed, how many at a time and what, specifically, is random in placing the objects.
Loled85 Loled85

2015/12/31

#
Yeah it was my limited amount of thoughts about that project-I tried the weirdest ways instead of just do the easy obvious way. Anyway just forget about it please ^^'
You need to login to post a reply.