7. +
class Island{
private boolean[][] boolPool;
public Island(String[] data){
boolPool=makePool(data);
}
public Island(boolean[][] boolPool){
this.boolPool=boolPool;
}
private boolean[][] makePool(String[] data){
boolean[][] tmp = new
boolean[data.length][data[0].length()];
for(int i=0;i<tmp.length;i++){
for(int j=0;j<tmp[i].length;j++){
tmp[i][j]=data[i].charAt(j)=='o';
}
}
return tmp;
}
8. +
public Island getClone(){
boolean[][] tmp = new boolean[boolPool.length][boolPool[0].length];
for(int i=0;i<tmp.length;i++){
for(int j=0;j<tmp[i].length;j++){
tmp[i][j]=boolPool[i][j];
}
}
return new Island(tmp);
}
public boolean[][] getBoolPool(){
return boolPool;
}
}
class Point{
public int x;
public int y;
public Point(int x,int y){
this.x=x;
this.y=y;
}
public Point[] getFourWay(){
Point[] points = new Point[4];
points[0]=new Point(x,y+1);
points[1]=new Point(x,y-1);
points[2]=new Point(x+1,y);
points[3]=new Point(x-1,y);
return points;
}
}