/**
* SpacecraftRadar its a radar to detect spacecrafts from the enemy
*
* @author (Esteban Montes)
* @version (a version number or a date)
*/
public class SpacecraftRadar
{
public static final int SPACEMAP_DIM = 10; //10x10
private int[][] spacemap;
public SpacecraftRadar()
{
this.setSpacemap(new int[SPACEMAP_DIM][SPACEMAP_DIM]);
/*
* Esto es solo para pruebas de funcionamiento que hago
*
* this.getSpacemap()[0][0] = 1;
* this.getSpacemap()[0][1] = 1;
* this.getSpacemap()[0][2] = 1;
* this.getSpacemap()[4][4] = 1;
* this.getSpacemap()[4][5] = 1;
* this.getSpacemap()[4][6] = 1;
* this.getSpacemap()[1][0] = 1;
* this.getSpacemap()[2][0] = 1;
* this.getSpacemap()[1][1] = 1;
* this.getSpacemap()[2][1] = 1;
*/
}
public int[][] getSpacemap()
{
return spacemap;
}
private void setSpacemap(int[][] spacemap)
{
if(spacemap != null && spacemap.length==SPACEMAP_DIM)
this.spacemap = spacemap;
}
public void rowDetection()
{
int counter = 0;
for(int i=0; i<this.getSpacemap()[0].length; i++){//numero de filas
for(int j=0; j<this.getSpacemap().length; j++){
if(this.getSpacemap()[i][j] == 1){
counter+=1;
if(counter == 3){
System.out.println("Dispara posicion: " + i + ":" + (j-1));
}
}else{
counter = 0;
}
}
}
}
public void colDetection()
{
int counter = 0;
for(int i=0; i<this.getSpacemap()[0].length; i++){//numero de filas
for(int j=0; j<this.getSpacemap().length; j++){
if(this.getSpacemap()[j][i] == 1){
counter+=1;
if(counter == 3){
System.out.println("Dispara posicion: " + (j-1) + ":" + i);
}
}else{
counter = 0;
}
}
}
}
}
buen
* _*
<\--♥
_/|_ "Para crear enemigos no es necesario declarar la guerra, es sólo decir lo que piensa."
<\--♥
_/|_ "Para crear enemigos no es necesario declarar la guerra, es sólo decir lo que piensa."