Skip to content
Snippets Groups Projects
Commit 7bccd77c authored by dragapsy's avatar dragapsy
Browse files

Tache 5 (La methode next() de la classe ColoredCellIterator) -Test passé avec succés-.

parent 6f35cc69
No related branches found
No related tags found
No related merge requests found
package model;
import javafx.scene.paint.Color;
import util.SetUtil;
import java.awt.*;
import java.util.HashSet;
......@@ -31,6 +32,13 @@ public class ColoredCellIterator implements Iterator<Cell> {
@Override
public Cell next() {
return null;
Cell Cell = SetUtil.anyElement(this.pendingCells);
this.pendingCells.remove(Cell);
this.visitedCells.add(Cell);
for (Cell neighbour : Cell.getNeighbours()){
if (Cell.getColor() == neighbour.getColor() && !(this.visitedCells.contains(neighbour))){
this.pendingCells.add(neighbour);
}
}
return Cell; }
}
......@@ -3,6 +3,7 @@ package model;
import javafx.beans.property.Property;
import javafx.scene.paint.Color;
import java.util.Iterator;
import java.util.List;
public class GrayCell extends AbstractCell{
......@@ -27,7 +28,11 @@ public class GrayCell extends AbstractCell{
*/
@Override
public void setNeighbours(List<Cell> cells) {
}
@Override
public Iterator<Cell> iterator() {
return null;
}
@Override
......
......@@ -11,8 +11,6 @@ import static org.assertj.core.api.Assertions.assertThat;
class ColoredCellIteratorTest {
// TODO
// uncomment
/*
* +---+---+---+
* | R | B | R |
......@@ -23,7 +21,15 @@ class ColoredCellIteratorTest {
* +---+---+---+
*/
/* private static ArrayGrid gridThreeThree = new ArrayGrid(3,3);
private static ArrayGrid gridThreeThree;
static {
try {
gridThreeThree = new ArrayGrid(3,3);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@BeforeAll
private static void initializeColorsGrid(){
......@@ -56,5 +62,5 @@ class ColoredCellIteratorTest {
assertThat(fromIteratorCells).hasSameElementsAs(expectedBlackCells).hasSameSizeAs(expectedBlackCells);
}
*/
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment