Ich möchte ein nichtgrafisches Koordinatensystem implementieren. Alle Koordinaten sollen 0 zurück liefern, es sei denn, es werden andere Werte zugewiesen. Was muß ich tun um zunächst den 1. Quadranten zu implementieren? Ich verstehe es nicht und bin schon länger da dran.
Java:
package langton;
public class Board {
int Matrix1 [][]= { {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0},{0,0,0,0,0} }; //1. Quadrant
int Matrixa [][]=new int [10000][10000];
int Matrix2 [][]= { {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0},{0,0,0,0,0} }; //2.
int Matrix3 [][]= { {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0},{0,0,0,0,0} }; //3.
int Matrix4 [][]= { {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0},{0,0,0,0,0} }; //4.
public int getstate (int x, int y){
int result=0;
if (x>=0 && x <=5 && y>=0 && y <= 5){ //1. Quadrant
result= Matrix1[x][y];
}else
if (x >=5 || y >= 5){int Matrixa [][]=new int[Matrix1.length+x][Matrix1[0].length+y];
result=Matrixa[Matrix1.length+x][Matrix1[0].length+y];
}
if (x<0 && y>=0){ //2. Quadrant
result= Matrix2[-1*x][y];
}
if (x<= 0 && y <0){ //3. Quadrant
result= Matrix3[-1*x][-1*y];
}
if (x>0 && y<0){ //4. Quadrant
result=Matrix4[x][-1*y];
}
return result;
}
public void setstate(int x,int y, int state1){
if (x>=0 && x<=5 && y>=0 &&y<=5){
Matrix1[x][y]=state1;}
else
if(x>=5 || y>=5){
Matrixa[x][y]=state1;
}
if (x<=0 && y<0){ //Im 3. Quadrant Werte setzen
Matrix3[-1*x][-1*y]=state1;
}
if (x>0 && y<0){ //Im 4. Quadrant Werte setzen
Matrix4[x][-1*y]=state1;
}
}}
Zuletzt bearbeitet von einem Moderator: