Skip to content
Snippets Groups Projects
Commit 40981004 authored by NGUYEN Thi hang's avatar NGUYEN Thi hang
Browse files

THN

parent 1ee33964
No related branches found
No related tags found
No related merge requests found
package model;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class ArrayGrid implements Grid{
......@@ -19,8 +21,28 @@ public class ArrayGrid implements Grid{
cells[i][j] = new SquareCell();
}
}
}}
}
for(int i=0; i< this.numberOfRows;i++){
for(int j=0; j< this.numberOfColumns; j++){
List<Cell> neighbours= new ArrayList<Cell>();
if (i==0)
neighbours.add(getCell(i+1,j));
if (i==numberOfRows-1)
neighbours.add(getCell(i-1,j));
if (j==0)
neighbours.add(getCell(i,j+1));
if (j==numberOfColumns-1)
neighbours.add(getCell(i, j-1));
else {
neighbours.add(getCell(i - 1, j));
neighbours.add(getCell(i, j - 1));
neighbours.add(getCell(i + 1, j));
neighbours.add(getCell(i, j + 1));
}
getCell(i,j).setNeighbours(neighbours);
}
}
}
@Override
public Cell getCell(int row, int column) {
return this.cells[row][column];
......
......@@ -3,7 +3,7 @@ package model;
import com.sun.prism.paint.Color;
public class ComputerPlayer implements Player{
PlayStrate sdfdsfdsfm
//PlayStrate sdfdsfdsfm
@Override
public boolean isHuman() {
return false;
......@@ -24,7 +24,7 @@ public class ComputerPlayer implements Player{
return null;
}
public javafx.scene.paint.Color play(){
return Color.RED;
return null ;// Color.RED;
}
}
......@@ -27,7 +27,8 @@ public class DistinctColorGenerator implements ColorGenerator {
}
for (int i = 0; i < colors.size(); i++) {
for (int j = 0; j < neighbor_colors.size(); j++) {
//if (colors.get(i)==neighbor_colors.get(j)) //break;//if (!(neighbor_colors.contains(colors.get(i)))){
if (colors.get(i)==neighbor_colors.get(j))
break;//if (!(neighbor_colors.contains(colors.get(i)))){
}
return this.colors.get(i);
......
......@@ -10,10 +10,10 @@ public class SquareCell extends AbstractCell{
private List<Cell> neighbours;
public SquareCell (){
this.setColor( DEFAULT_CELL_COLOR);
this.neighbours=new ArrayList<Cell>();
}
public SquareCell(Color color){
this.setColor(color);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment