In a class create an array list of elements of another class, help!
I have created class Square, boxes 1x1x1 with different properties like walls and doors etc. Doors can be open or closed.
Now I need to create class of collections of these squares, class Dungeon. Each dungeon must have its own (ordinary) system of coordinates in the beginning in the square with most northern (x), western (y) and low(z) position. (so another squares will only have positive coordinates). Each square has to border at least with one another square. More, it may not be anything plased on (x,x,x).
I also have to create "spaces", made by squares with open doors.
I want to make a constructor in class Dungeon that will first create a new element of Square, give it zero-coordinates, then create new squares that will border with the previous in a direction that constructor will choose. (Is it a good idea and how to make it choose it?) While creating new squares I will get their coordinates and put it into array, also check that the coordinate will not be (x,x,x), where x- any integer.
I am not sure about how to create spaces without making a new class, please if you have any ideas, help!
https://sites.google.com/site/podzemelja/
Re: In a class create an array list of elements of another class, help!
Quote:
Originally Posted by
LadyBelka
I am not sure about how to create spaces without making a new class, please if you have any ideas, help!
?? You said spaces are made by squares with open doors...
Re: In a class create an array list of elements of another class, help!
yes if they are neighbors and there is an open door between them, but they can be more than two, actually. The point is that you can freely go from any of them to any other in this spaces
Re: In a class create an array list of elements of another class, help!
You asked for help creating spaces without making a new class, but you say spaces are made by squares with open doors - which obviously suggests you can make spaces by using squares with open doors.
I'm afraid I really don't understand your problem, or the relevance of your last post.