diff --git a/app/src/main/java/model/ArrayGrid.java b/app/src/main/java/model/ArrayGrid.java index c75fa18e09ee3cb2cb3769d6f30ff497709f623e..8838c6431b8810f711a7c8f8ec29da75bc4e7db7 100644 --- a/app/src/main/java/model/ArrayGrid.java +++ b/app/src/main/java/model/ArrayGrid.java @@ -1,6 +1,8 @@ package model; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; public class ArrayGrid implements Grid{ @@ -17,10 +19,30 @@ public class ArrayGrid implements Grid{ for (int i=0; i< numberOfRows;i++){ for (int j=0; j < numberOfColumns; j++){ 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]; diff --git a/app/src/main/java/model/ColoredCellIerator.java b/app/src/main/java/model/ColoredCellIerator.java index 0800efb3bd402c0a77c446ea111b87d7af74f2e8..43dfb40cbb232e6391f45c9574efaa763b09317f 100644 --- a/app/src/main/java/model/ColoredCellIerator.java +++ b/app/src/main/java/model/ColoredCellIerator.java @@ -7,7 +7,7 @@ import util.SetUtil; import java.util.*; -public class ColoredCellIerator{ /*implements Iterator<Cell> { +public class ColoredCellIerator {/*implements Iterator<Cell> { Color color; List<Cell> cells; diff --git a/app/src/main/java/model/ComputerPlayer.java b/app/src/main/java/model/ComputerPlayer.java index a8699402c02b3c81f037f788be7b7dd71eeae6d0..b97bf17de1df754bb2ab0fbf93b27bd36fa7e2aa 100644 --- a/app/src/main/java/model/ComputerPlayer.java +++ b/app/src/main/java/model/ComputerPlayer.java @@ -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; } } diff --git a/app/src/main/java/model/DistinctColorGenerator.java b/app/src/main/java/model/DistinctColorGenerator.java index f2eb4e2eed7f691b57620fa1421d38378baf7e8e..3a70a733ef686913ac6eb5250c367bfcd76d770e 100644 --- a/app/src/main/java/model/DistinctColorGenerator.java +++ b/app/src/main/java/model/DistinctColorGenerator.java @@ -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); diff --git a/app/src/main/java/model/SquareCell.java b/app/src/main/java/model/SquareCell.java index d4941b2447a7d844e8924783f0ec6637fb7a131c..617bb82c197a524850a82d7ea88ad47eba356f3a 100644 --- a/app/src/main/java/model/SquareCell.java +++ b/app/src/main/java/model/SquareCell.java @@ -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);