Skip to content
Snippets Groups Projects
Commit 301fc6c5 authored by RAKOTOARISOA Andrianinarisaina cy's avatar RAKOTOARISOA Andrianinarisaina cy
Browse files

Tâche 5 (8.1) : Modification de la classe ColoredCellIterator, sur la méthode...

Tâche 5 (8.1) : Modification de la classe ColoredCellIterator, sur la méthode implémentée "getNeighbours"
parent 0d1891b5
No related branches found
No related tags found
No related merge requests found
package model;
import javafx.beans.property.Property;
import javafx.scene.paint.Color;
......
package model;
import javafx.beans.property.Property;
import java.awt.*;
import java.util.Iterator;
import java.util.Set ;
public class ColorCellIterator implements Iterator<Cell> {
//Iterator<Cell> implemente un tableau de cellule
public class ColoredCellIterator<Cell> implements Iterator<Cell> {
Color color ; // qui correspond à la couleur de la cellule de départ
Set<Cell> visitedCells ; //pour stocker l’ensemble des cellules sur lesquelles on a déjà itéré
......@@ -13,32 +15,60 @@ public class ColorCellIterator implements Iterator<Cell> {
//Constructeur de la classe
public void ColoredCellIterator(Cell startCell) { //startCell : cellule à partir de laquelle on souhaite démarrer l’itération
this.pendingCells.add(startCell) ;
this.visitedCells.add(startCell) ;
}
@Override
//Méthode implémentée
Color getColor() {
return null;
}
//Méthode implémentée
void setNeighbours(Set<Cell> cells) {}
//Méthode implémentée
public Property<Color> getColorProperty() {
return null ;
} ;
//Demandée par l'exercice
Iterator<Cell> iterator() {
return null;
} ;
//Méthode implémentée
public boolean hasNext() {
return false;
}
@Override
//Méthode implémentée
public Cell next() {
return null;
}
//Set est une collection - pas d'element identique
//List c est une liste - avec des element identique
public Set<Cell> getNeighbours() {
while (this.pendingCells.iterator().hasNext()) {
Cell pendingCell = this.pendingCells.iterator().next();
if (pendingCell.iterator().hasNext().getColor() == pendingCells.getColor()) {
this.pendingCells.add(pendingCell);
//ColorCellIterator pendingCells = new ColorCellIterator() ;
ColoredCellIterator pendingCellsNext = (ColoredCellIterator) this.pendingCells.iterator().next();
while (pendingCellsNext.iterator().hasNext()) {
if (pendingCellsNext.iterator() == this.pendingCells.iterator()) {
this.pendingCells.add((Cell) pendingCellsNext);
}
//this.visitedCells.add((Cell) pendingCells);
}
this.visitedCells.add(pendingCell);
if (this.pendingCells.iterator().hasNext()) {
pendingCell = this.pendingCells.iterator().next();
/*if (this.pendingCells.iterator().hasNext()) {
pendingCells = (ColoredCellIterator) this.pendingCells.iterator().next();
}
else return this.visitedCells;
*/
}
return null;
}
}
......@@ -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{
......@@ -30,6 +31,11 @@ public class GrayCell extends AbstractCell{
}
@Override
public Iterator<Cell> iterator() {
return null;
}
@Override
public void setColor(Color color){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment