so I am new to programming and having some issues with classes. I am using the lens next brick. There is a class from the libuary called Node. It takes a X and Y. Like so:
Node nodeNameOne = new Node(2,3);
What I want to do:
I have a 12 by 12 array. And for each position in the array I want to get its X and Y and create a new node. The problem is I want to automatically change the " nodeNameOne" .
My solution was to create a intiger variable and increment it, then do a .to string and use that as the nodes name by when I use my intiger variable name it uses the name of the variable not the value within the variable.
I have looked at other posts that sujest using "Class.newInstance" but I can't get this to work.
Any help is appreciated. Thanks
UPDATE:
I have a 12 by 12 array. I will scan the array and when I detect a 0 in any position of the array i want to create a new Node with the X and Y of the array position.
because it is a 12 by 12 array there are 144 possible places that 0 can occur. therefore the code that is needed to make a new is node is: Node nodename = new Node(x,y);
I want to automate the instance name: "nodeName" to use a string variable, that I will get from:
int nameOfNode= 0;
String temp = Integer.toString(nameOfNode);
Node temp = new Node(x,y);
nameOfNode++;
the error i get is that it says that temp is already used, but i know that. i want it to use the value of temp not the name "temp". - i hope this is clearer.