Skip to content
Snippets Groups Projects
Commit c7504db9 authored by Yanis OUALAN's avatar Yanis OUALAN
Browse files

fix syntaxe

parent 20e24e55
No related branches found
No related tags found
No related merge requests found
Pipeline #39138 passed
gradlew 100644 → 100755
File mode changed from 100644 to 100755
...@@ -23,6 +23,7 @@ public class SimulatorApplication extends javafx.application.Application { ...@@ -23,6 +23,7 @@ public class SimulatorApplication extends javafx.application.Application {
private Stage primaryStage; private Stage primaryStage;
private Parent view; private Parent view;
private void initializePrimaryStage(Stage primaryStage) { private void initializePrimaryStage(Stage primaryStage) {
this.primaryStage = primaryStage; this.primaryStage = primaryStage;
this.primaryStage.setTitle(APP_NAME); this.primaryStage.setTitle(APP_NAME);
...@@ -45,7 +46,7 @@ public class SimulatorApplication extends javafx.application.Application { ...@@ -45,7 +46,7 @@ public class SimulatorApplication extends javafx.application.Application {
view = loader.load(); view = loader.load();
Controller controller = loader.getController(); Controller controller = loader.getController();
controller.initialize(BOX_WIDTH, BOX_HEIGHT, COLUMN_COUNT, ROW_COUNT, controller.initialize(BOX_WIDTH, BOX_HEIGHT, COLUMN_COUNT, ROW_COUNT,
INITIAL_FIRE_COUNT, INITIAL_FIREFIGHTER_COUNT, INITIAL_CLOUD_COUNT); INITIAL_FIRE_COUNT, INITIAL_FIREFIGHTER_COUNT);
} }
private void showScene() { private void showScene() {
......
...@@ -11,16 +11,19 @@ public class EmptySquare implements Entity{ ...@@ -11,16 +11,19 @@ public class EmptySquare implements Entity{
private Position position; private Position position;
private final Color viewColor = Color.WHITE; private final Color viewColor = Color.WHITE;
private int age; private int age;
public EmptySquare(Position p) { public EmptySquare(Position p) {
this.position = p; this.position = p;
this.age = -999; this.age = -999;
} }
public EmptySquare(Position p, int age) { public EmptySquare(Position p, int age) {
this.position = p; this.position = p;
this.age = age; this.age = age;
} }
@Override @Override
public List<Position> nextTurn(Board<Entity> board) { public List<Position> nextTurn(Board<Square> board) {
return new ArrayList<Position>(); return new ArrayList<Position>();
} }
...@@ -37,6 +40,7 @@ public class EmptySquare implements Entity{ ...@@ -37,6 +40,7 @@ public class EmptySquare implements Entity{
public Color getViewColor() { public Color getViewColor() {
return this.viewColor; return this.viewColor;
} }
@Override @Override
public int getAge() { public int getAge() {
return this.age; return this.age;
...@@ -46,4 +50,9 @@ public class EmptySquare implements Entity{ ...@@ -46,4 +50,9 @@ public class EmptySquare implements Entity{
public void incrementAge() { public void incrementAge() {
age = age + 1; age = age + 1;
} }
@Override
public void setAge(int age) {
this.age = age;
}
} }
...@@ -120,9 +120,6 @@ public class FireFighterScenario extends EntityScenario implements Board<Square> ...@@ -120,9 +120,6 @@ public class FireFighterScenario extends EntityScenario implements Board<Square>
return matrix.getRows(); return matrix.getRows();
} }
public int columnCount() {
return matrix.getColumns();
public int columnCount() { public int columnCount() {
return matrix.getColumns(); return matrix.getColumns();
} }
......
...@@ -3,9 +3,6 @@ package model; ...@@ -3,9 +3,6 @@ package model;
import util.Matrix; import util.Matrix;
public interface Scenario { public interface Scenario {
<<<<<<< HEAD
public void initScenario(Matrix<Square> matrix); public void initScenario(Matrix<Square> matrix);
=======
public void initScenario(Matrix<Entity> matrix);
>>>>>>> d8a3bf456f5b3471a26e38f4c2d9f5ccef27b158
} }
\ No newline at end of file
package model;
import javafx.scene.paint.Color;
import util.Position;
import util.PositionUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class cloud implements Entity{
private int age;
private final Color viewColor = Color.GREY;
private Position position;
Board<Entity> b;
public cloud (Position position, Board<Entity> b, int age){
this.age = age;
this.position = position;
this.b = b;
}
@Override
public List<Position> nextTurn(Board<Entity> b) {
List<Position> positions = new ArrayList<>();
// Générer les positions adjacentes valides
List<Position> possibleMoves = PositionUtil.generateAllAdjacentPositions(position, b);
// Sélectionner une position aléatoire parmi les mouvements possibles
Position next_pos = possibleMoves.get(new Random().nextInt(possibleMoves.size()));
// Vérifier l'état de la nouvelle position
ArrayList<Entity> nextEntities = b.getState(next_pos);
positions.add(position);
positions.add(next_pos);
// Si la nouvelle position contient un feu, éteindre le feu
if (nextEntities.contains(Fire.class)) {
extinguish(List.of(next_pos), b);
}
b.setState(this, next_pos);
// Retourner la position mise à jour pour affichage ou suivi
return positions;
}
private List<Position> extinguish(List<Position> next_pos, Board<Entity> b) {
List<Position> extinguishedPositions = new ArrayList<>();
if (b.getState(next_pos.get(0)).contains(Fire.class)) {
b.clearCase(next_pos.get(0));
extinguishedPositions.add(next_pos.get(0));
}
return extinguishedPositions;
}
@Override
public Position getPosition() {
return position;
}
@Override
public void setPosition(Position p) {
this.position = p;
}
@Override
public int getAge() {
return this.age;
}
@Override
public void incrementAge() {
this.age += 1;
}
@Override
public Color getViewColor() {
return viewColor;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment