Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
1 result

Target

Select target project
  • travers.c/flooding-template
  • g20031427/flooding-template
  • p20006624/flooding-template
  • b21221851/tp-6
  • n19028187/flooding-template
  • e21221636/tp-6-flood
  • saddem.r/flooding-template
  • r20029383/flooding-template
  • s21226517/flooding-template
  • r20004714/flooding-template
  • e20026270/flooding-template-el-ghaouti-aymane
  • o21205600/flooding-template
12 results
Select Git revision
  • main
1 result
Show changes
Commits on Source (14)
......@@ -6,5 +6,8 @@ Il s'agit d'implémenter une version du jeu "inondation" (voir par exemple [ici]
## Membre du projet
- NOM, prénom
- NOM, prénom
- SAIDI Hatim 2.2
- NSSAIRY Mohamed-Amine 2.1
- AIX MONTERRIN
package model;
import java.util.Iterator;
public class ArrayGrid implements Grid{
private Cell[][] cells;
private final int numberOfRows ;
private final int numberOfColumns ;
public ArrayGrid(int numberOfRows,int numberOfColumns) {
this.numberOfRows = numberOfRows;
this.numberOfColumns = numberOfColumns;
if (numberOfColumns <= 0 || numberOfRows <= 0) {
throw new IllegalArgumentException();
}
else {
for (int j = 0; j < this.numberOfColumns; j++) {
for (int i = 0; i < this.numberOfRows; i++) {
cells[i][j] = new SquareCell();
}
}
}
}
public Cell getCell(int row, int column) {
return this.cells[row][column];
}
public int getNumberOfRows(){
return this.numberOfRows;
}
public int getNumberOfColumns(){
return this.numberOfColumns;
}
public void color(ColorGenerator colorGenerator){
for(Cell cell : this)
cell.setColor(colorGenerator.nextColor(new SquareCell()));
}
public Iterator<Cell> iterator(){
return null ;
}
}
......@@ -40,4 +40,8 @@ public class GrayGrid implements Grid{
public int getNumberOfColumns() {
return numnberOfColumns;
}
public void color(ColorGenerator colorGenerator){
}
}
package model;
public interface Grid {
public interface Grid extends Iterable<Cell>{
/**
* Return the cell located at the given coordinates in the grid.
......@@ -28,4 +28,5 @@ public interface Grid {
* The new color of {@code cell} is obtained by calling the method {@code nextColor}
*/
void color(ColorGenerator colorGenerator);
}
......@@ -2,6 +2,8 @@ package model;
import javafx.scene.paint.Color;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
......@@ -9,27 +11,31 @@ public class SquareCell extends AbstractCell{
List<Cell> neighbours;
public SquareCell() {
Color cell = DEFAULT_CELL_COLOR;
this.neighbours = new ArrayList<>();
}
public SquareCell(Color color){
Color cell = color;
this.neighbours = new ArrayList<>();
}
public SquareCell(Color color,List<Cell>neighbours){
Color cell = color;
this.neighbours = neighbours;
}
/**
* A cell is placed somewhere on a grid. Its neighbours thus depend on the underlying grid.
*
* @return the list of cell that are neighbours of this{@code Cell}.
*/
@Override
public List<Cell> getNeighbours() {
return null;
return this.neighbours;
}
/**
* Update the list of neighbours of this {@code Cell}.
*
* @param cells a list of cells that are the neighbours of this {@code cell}
* int the underlying grid.
*/
@Override
public void setNeighbours(List<Cell> cells) {
for (int i = 0; i < neighbours.size() ; i++) {
this.neighbours.set(i,cells.get(i));
}
}
}
\ No newline at end of file
package model;
import javafx.scene.paint.Color;
public class UniformColorGenerator implements ColorGenerator{
public Color nextColor(Cell cell){
return cell.getColor();
}
}
......@@ -11,8 +11,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
class ArrayGridTest {
// TODO
// uncomment
/*
private ArrayGrid arrayGridThreeFour;
private final ArrayGrid arrayGridTwoTwo = new ArrayGrid(2,2);
......