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

Ajout des classes Fire et FireFighter

parent bba469f7
No related branches found
No related tags found
No related merge requests found
Pipeline #38237 passed
...@@ -4,9 +4,14 @@ import util.Position; ...@@ -4,9 +4,14 @@ import util.Position;
public class FireFighter implements Entity{ public class FireFighter implements Entity{
private Position position; private Position position;
public void nextTurn(){ public FireFighter(Position position){
this.position = position;
}
public void nextTurn(Board b){
// Récupérer la position // Récupérer la position
//Si un feu est à proximité : éteindre les feux à x + 1 y, x y+1, x+1 y-1, x-1 y+1 //Si un feu est à proximité : éteindre les feux à x + 1 y, x y+1, x+1 y-1, x-1 y+1
//Sinon
//Se déplacer vers le feu le plus proche
//Si un feu est à proximité : éteindre les feux à x + 1 y, x y+1, x+1 y-1, x-1 y+1 //Si un feu est à proximité : éteindre les feux à x + 1 y, x y+1, x+1 y-1, x-1 y+1
// Ajouter un feu à x + 1 y, x y+1, x+1 y-1, x-1 y+1 // Ajouter un feu à x + 1 y, x y+1, x+1 y-1, x-1 y+1
} }
......
package model;
import java.util.List;
import util.*;
public class FireFighterScenario implements Board<Entity>{
/**
* Get the state of the board at a specific position.
*
* @param position The position on the board for which to retrieve the state.
* @return The state at the specified position.
*/
public Entity getState(Position position){
throw new IllegalStateException("Method not implemented");
}
/**
* Set the state of a specific position on the board to the specified state.
*
* @param state The state to set for the given position.
* @param position The position on the board for which to set the state.
*/
public void setState(Entity state, Position position){
throw new IllegalStateException("Method not implemented");
}
/**
* Get the number of rows in the board.
*
* @return The number of rows in the board.
*/
public int rowCount(){
throw new IllegalStateException("Method not implemented");
}
/**
* Get the number of columns in the board.
*
* @return The number of columns in the board.
*/
public int columnCount(){
throw new IllegalStateException("Method not implemented");
}
/**
* Update the board to its next generation or state. This method may modify the
* internal state of the board and return a list of positions that have changed
* during the update.
*
* @return A list of positions that have changed during the update.
*/
public List<Position> updateToNextGeneration(){
throw new IllegalStateException("Method not implemented");
}
/**
* Reset the board to its initial state.
*/
public void reset(){
throw new IllegalStateException("Method not implemented");
}
/**
* Get the current step number or generation of the board.
*
* @return The current step number or generation.
*/
public int stepNumber(){
return 0;
}
}
...@@ -112,9 +112,11 @@ public class FirefighterBoard implements Board<List<ModelElement>> { ...@@ -112,9 +112,11 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
modifiedPosition.add(newFirefighterPosition); modifiedPosition.add(newFirefighterPosition);
List<Position> neighborFirePositions = neighbors.get(newFirefighterPosition).stream() List<Position> neighborFirePositions = neighbors.get(newFirefighterPosition).stream()
.filter(firePositions::contains).toList(); .filter(firePositions::contains).toList();
for (Position firePosition : neighborFirePositions) for (Position firePosition : neighborFirePositions){
extinguish(firePosition);
modifiedPosition.addAll(neighborFirePositions); modifiedPosition.addAll(neighborFirePositions);
extinguish(firePosition);
}
} }
firefighterPositions = firefighterNewPositions; firefighterPositions = firefighterNewPositions;
return modifiedPosition; return modifiedPosition;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment