dentro de una clase cree unos metodos para leer matrices de caracteres (char) de tal manera que recorriendolas de forma horizontal de izq a der me diera el caracter que esta en la posicion ... y ademas me de la posicion(las coordenadas) ... es algo como :
CÓDIGO
public class unaClase {
private static int x;
private static int y;
private char[][] Matriz;
private int TAM_MATRIZ;
public unaClase(char Letras[][]) {
this.Matriz = Letras;
this.TAM_MATRIZ = Matriz.length-1;
}
public char getPrimero() {
x = y = 0;
return Matriz[y][x];
}
public char getSgte() {
if(x == TAM_MATRIZ) { x = 0; y++; return Matriz[y][x]; }
else { x++; return Matriz[y][x]; }
}
public boolean tieneSgte() {
if(x == TAM_MATRIZ) {
if(y+1 > TAM_MATRIZ) return false;
else return true;
} else return true;
}
public int getx() {
return this.x;
}
public int gety() {
return this.y;
}
}
private static int x;
private static int y;
private char[][] Matriz;
private int TAM_MATRIZ;
public unaClase(char Letras[][]) {
this.Matriz = Letras;
this.TAM_MATRIZ = Matriz.length-1;
}
public char getPrimero() {
x = y = 0;
return Matriz[y][x];
}
public char getSgte() {
if(x == TAM_MATRIZ) { x = 0; y++; return Matriz[y][x]; }
else { x++; return Matriz[y][x]; }
}
public boolean tieneSgte() {
if(x == TAM_MATRIZ) {
if(y+1 > TAM_MATRIZ) return false;
else return true;
} else return true;
}
public int getx() {
return this.x;
}
public int gety() {
return this.y;
}
}
esa seria la clase de donde tngo la matriz y los metodos para recorrer la matriz...
luego .. desde otra clase mi idea era recorrer de esta manera la matriz
CÓDIGO
unaClase ASD = new unaClase(Matriz);
for(char c = ASD.getPrimero(); ASD.tieneSgte(); c = ASD.getSgte()) {
algunaFuncion(c);
x = ASD.getx();
y = ASD.gety();
}
for(char c = ASD.getPrimero(); ASD.tieneSgte(); c = ASD.getSgte()) {
algunaFuncion(c);
x = ASD.getx();
y = ASD.gety();
}
pero cuando ago una prueba .. me tira todos los elementos de la matriz menos el ultimo ... no hay ni un problema antes .. pero al final ... e intentado varias formas .. pero nada ... es un problema bastante trivial .. pero no le pillo la falla xD .. aer si alguien me puede ayudar pls!!!