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 (6)
# Flooding
## Description du projet
Il s'agit d'implémenter une version du jeu "inondation" (voir par exemple [ici]([Flood-it!](https://unixpapa.com/floodit), ainsi que des intelligences artificiels simples pour y jouer.
## Membre du projet
- RAKOTOARISOA, Andrianina
- NOM, prénom
- NOM, prénom
package model;
public class ArrayGrid implements model.Grid {
//Tableau pour stocker les cellules
model.Cell[][] cells ;
//Nombre de lignes
int numberOfRows ;
//Nombre de colonnes
int numberOfColumns ;
//Constructeur
//Une grille avec les nombres de lignes et de colonnes passés en arguments
//Ce constructeur initialise le tableau cells aux bonnes dimensions et remplit les cases avec des instances de SquareCell
public ArrayGrid(int numberOfRows, int numberOfColumns) {
//Traitement des exceptions pour eviter que le programme se termine non connecté
if (numberOfRows <= 0 && numberOfColumns <= 0)
throw new IllegalArgumentException("valeur argument négatif ou nul");
else
for (int i = 0 ; i < numberOfRows ;i++)
for (int j = 0 ; j < numberOfRows ; j++)
cells[i][j] = new SquareCell() ;
}
//Demander par l'exercice
public void color(ColorGenerator[] colorGenerator) {
for (int i = 0 ; i < numberOfRows ; i++)
for (int j = 0 ; j < numberOfColumns ; j++) {
colorGenerator = new ColorGenerator[]{} ;
//cells[i][j].setColor(colorGenerator.nextColor());
}
}
@Override
public void color(ColorGenerator colorGenerator) {
}
@Override
public model.Cell getCell(int row, int column) {
return null;
}
@Override
public int getNumberOfRows() {
return 0;
}
@Override
public int getNumberOfColumns() {
return 0;
}
}
......@@ -9,6 +9,12 @@ public class GrayGrid implements Grid{
this.numberOfRows = numberOfRows;
this.numnberOfColumns = numberOfColumns;
}
@Override
public void color(ColorGenerator colorGenerator) {
}
/**
* Return the cell located at the given coordinates in the grid.
*
......
package model;
public interface Grid {
import java.util.Iterator;
/**
* Return the cell located at the given coordinates in the grid.
* @param row the row of the returned the cell
* @param column the column of the returned cell
* @return the cell located in row {@code row} and in column {@code column}
*/
// l'Interface Iterable<Cell> n'a qu'une seule méthode nommée iterator()
public interface Grid extends Iterable<Cell> {
//Méthode demandée par l'exercice
public default void color(ColorGenerator colorGenerator) {
for (Cell cell : this) ;
};
//Méthode getCell
Cell getCell(int row, int column);
/**
* Return the number of rows of this {@code Grid}
* @return the number of rows of this {@code Grid}
*/
// definition de la methode iterator()
public Iterator<Cell> iterator();
//Méthode getNumberOfRows
int getNumberOfRows();
/**
......
......@@ -2,19 +2,37 @@ package model;
import javafx.scene.paint.Color;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class SquareCell extends AbstractCell{
List<Cell> neighbours;
Color color ;
//constructeur 1 : un constructeur sans paramètres qui construit une liste de cellule vide
//de couleur DEFAULT_CELL_COLOR avec une liste de voisins vide
public void SquareCell() {
this.neighbours = new ArrayList<Cell>() ;
color = DEFAULT_CELL_COLOR ;
}
//Constructeur 2 : un constructeur ayant en paramètre une couleur color
//qui construit une cellule de couleur color et dont les voisins sont vides
public void SquareCell(Color color) {
this.neighbours = new ArrayList<Cell>() ;
this.color = color ;
}
//Constructeur 3 : un constructeur avec deux paramètres : "Color color" et "ArrayList<Cell> neighbours
//qui consrtuit une cellule de couleur color et dont les cellules voisines sont neighours
//@Override
public void SquareCell(Color color, List<Cell> neighbours) {
this.neighbours = neighbours ;
this.color = color ;
}
/**
* 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;
......
//7.2 Classe UniformColorGenerator
// Cette classe correspong à un coloriage uniforme de la grille
package model;
import javafx.scene.paint.Color;
public class UniformColorGenerator implements ColorGenerator{
Color couleur ;
//Constructeur de la classe
public void UniformColorGenerator(Color couleur) {
this.couleur = couleur ;
}
@Override
public Color nextColor(Cell cell) {
return this.couleur ;
}
}
......@@ -28,12 +28,14 @@ public class MatrixPane extends GridPane {
this.tileHeight = tileHeight;
this.numberOfColumns = numberOfColumns;
this.numberOfRows = numberOfRows;
// TODO replace by new ArrayGrid(numberOfRows, numberOfColumns)
cellGrid = new GrayGrid(numberOfRows, numberOfColumns);
//Changement du constructeur "GrayGrid" en "ArrayGrid"
//cellGrid = new GrayGrid(numberOfRows, numberOfColumns);
cellGrid = new model.ArrayGrid(numberOfRows, numberOfColumns);
initMatrix();
}
public void setGameController(GameController controller) {
this.controller = controller;
}
......
......@@ -11,12 +11,11 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
class ArrayGridTest {
// TODO
// uncomment
/*
private ArrayGrid arrayGridThreeFour;
private final ArrayGrid arrayGridTwoTwo = new ArrayGrid(2,2);
public static void Main (String arg[]) {}
@BeforeEach
void initializeArrayGridThreeFour(){
arrayGridThreeFour = new ArrayGrid(3,4);
......@@ -89,5 +88,5 @@ class ArrayGridTest {
assertThat(iterator.hasNext()).isFalse();
}
*/
}
\ No newline at end of file