Normal
Ich habe einige objekte erstellt und die möchte ich jetzt in einem array an der position von klassenattribut x speichern, gibt es eine schlauere Methode als diese hier[CODE=java]class Figur{ private int x; private int y; // getter setter Konstruktor}class Spiel public static void main(String []args){ Figur f1=new Figur(0,0); Figur f2=new Figur(0,1); // usw... Figur[][]b=new Figur[10][10]; b[f1.getx][f1.gety]=f1; b[f2.getx][f2.gety]=f2; //usw... }[/CODE]
Ich habe einige objekte erstellt und die möchte ich jetzt in einem array an der position von klassenattribut x speichern, gibt es eine schlauere Methode als diese hier
[CODE=java]class Figur{
private int x;
private int y;
// getter setter Konstruktor
}class Spiel
public static void main(String []args){
Figur f1=new Figur(0,0);
Figur f2=new Figur(0,1);
// usw...
Figur[][]b=new Figur[10][10];
b[f1.getx][f1.gety]=f1;
b[f2.getx][f2.gety]=f2;
//usw...
}[/CODE]