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; package model;
import javafx.beans.property.Property; import javafx.beans.property.Property;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
......
package model; package model;
import javafx.beans.property.Property;
import java.awt.*; import java.awt.*;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set ; 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 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é 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> { ...@@ -13,32 +15,60 @@ public class ColorCellIterator implements Iterator<Cell> {
//Constructeur de la classe //Constructeur de la classe
public void ColoredCellIterator(Cell startCell) { //startCell : cellule à partir de laquelle on souhaite démarrer l’itération public void ColoredCellIterator(Cell startCell) { //startCell : cellule à partir de laquelle on souhaite démarrer l’itération
this.pendingCells.add(startCell) ; 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() { public boolean hasNext() {
return false; return false;
} }
@Override //Méthode implémentée
public Cell next() { public Cell next() {
return null; return null;
} }
//Set est une collection - pas d'element identique
//List c est une liste - avec des element identique
public Set<Cell> getNeighbours() { public Set<Cell> getNeighbours() {
while (this.pendingCells.iterator().hasNext()) { while (this.pendingCells.iterator().hasNext()) {
Cell pendingCell = this.pendingCells.iterator().next(); //ColorCellIterator pendingCells = new ColorCellIterator() ;
if (pendingCell.iterator().hasNext().getColor() == pendingCells.getColor()) { ColoredCellIterator pendingCellsNext = (ColoredCellIterator) this.pendingCells.iterator().next();
this.pendingCells.add(pendingCell);
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()) { /*if (this.pendingCells.iterator().hasNext()) {
pendingCell = this.pendingCells.iterator().next(); pendingCells = (ColoredCellIterator) this.pendingCells.iterator().next();
} }
else return this.visitedCells; else return this.visitedCells;
*/
} }
return null;
} }
} }
...@@ -3,6 +3,7 @@ package model; ...@@ -3,6 +3,7 @@ package model;
import javafx.beans.property.Property; import javafx.beans.property.Property;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import java.util.Iterator;
import java.util.List; import java.util.List;
public class GrayCell extends AbstractCell{ public class GrayCell extends AbstractCell{
...@@ -30,6 +31,11 @@ public class GrayCell extends AbstractCell{ ...@@ -30,6 +31,11 @@ public class GrayCell extends AbstractCell{
} }
@Override
public Iterator<Cell> iterator() {
return null;
}
@Override @Override
public void setColor(Color color){ 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