Skip to content
Snippets Groups Projects
Commit eb9963e0 authored by Yanis O's avatar Yanis O
Browse files

[Modif] FireFighterScenario rempli la matrice de cases vides

parent 1298cabf
No related branches found
No related tags found
No related merge requests found
......@@ -39,3 +39,4 @@ bin/
*.bin
*.lock
.gradle/8.10.2/executionHistory/executionHistory.bin
build/
\ No newline at end of file
package model;
import javafx.scene.paint.Color;
import util.Position;
public class EmptySquare implements Entity{
private Position position;
private final Color viewColor = Color.WHITE;
public EmptySquare(Position p){
this.position = p;
}
......@@ -23,4 +25,7 @@ public class EmptySquare implements Entity{
this.position = p;
}
public Color getViewColor(){
return this.viewColor;
}
}
package model;
import javafx.scene.paint.Color;
import util.Position;
public interface Entity {
public void nextTurn(Board<Entity> board);
public Position getPosition();
public void setPosition(Position p);
public Color getViewColor();
}
package model;
import javafx.scene.paint.Color;
import util.Position;
public class Fire implements Entity{
Board<Entity> b;
private Position position;
private final Color viewColor = Color.RED;
public Fire(Position position, Board<Entity> b){
this.position = position;
}
......@@ -20,4 +22,8 @@ public class Fire implements Entity{
public Position getPosition() {
return this.position;
}
public Color getViewColor(){
return this.viewColor;
}
}
package model;
import javafx.scene.paint.Color;
import util.Position;
public class FireFighter implements Entity{
private Position position;
private final Color viewColor = Color.BLUE;
public FireFighter(Position position){
this.position = position;
......@@ -26,6 +28,9 @@ public class FireFighter implements Entity{
public Position getPosition() {
return this.position;
}
public Color getViewColor(){
return this.viewColor;
}
}
......@@ -11,8 +11,13 @@ public class FireFighterScenario implements Board<Entity>{
private Matrix<Entity> matrix;
private int step;
public FireFighterScenario(int boardSize){
this.matrix = new Matrix<Entity>();
public FireFighterScenario(int columns, int rows, int initialFireCount, int initialFireFightersCount){
this.matrix = new Matrix<Entity>(columns, rows);
for(int x = 0; x < matrix.getRows(); x++){
for(int y = 0; y < matrix.getColumns(); y++){
matrix.set(x,y, new EmptySquare(new Position(x, y)));
}
}
this.step = 0;
}
public Entity getState(Position position){
......@@ -39,11 +44,11 @@ public class FireFighterScenario implements Board<Entity>{
public int rowCount(){
return matrix.size();
return matrix.getRows();
}
public int columnCount(){
return matrix.size(); // On considère que la matrice est toujours une matrice carré
return matrix.getColumns();
}
public List<Position> updateToNextGeneration() {
......@@ -70,6 +75,7 @@ public class FireFighterScenario implements Board<Entity>{
public int stepNumber(){
this.step++;
return this.step;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment