Skip to content
Snippets Groups Projects
Commit 48220ee0 authored by MAAZOUZ Ilyas's avatar MAAZOUZ Ilyas
Browse files

hjklh

parent 3f6a814e
No related branches found
No related tags found
No related merge requests found
Pipeline #24919 passed
...@@ -2,5 +2,5 @@ package model; ...@@ -2,5 +2,5 @@ package model;
//this class represents two types of constant Firefighter or fire //this class represents two types of constant Firefighter or fire
public enum ModelElement { public enum ModelElement {
FIREFIGHTER, FIRE , FIREFIGHTER, FIRE ,NOT
} }
...@@ -36,9 +36,11 @@ public class Fboard { ...@@ -36,9 +36,11 @@ public class Fboard {
} }
} }
for(item item : items){ for(item item : items){
// Remove Extinguished position from the results
if(item.getID()==0){ if(item.getID()==0){
result.addAll(item.update(this)); result.addAll(item.update(this));
} }
} }
step++; step++;
return result; return result;
...@@ -64,15 +66,15 @@ public class Fboard { ...@@ -64,15 +66,15 @@ public class Fboard {
} }
} }
// A revoir
public Fire getFire() { public Fire getFire() {
Fire x = null; Fire x = null;
for (item e : items) { for (item e : items) {
if (e.getID() == 1) { if (e.getID() == 1) {
x = (Fire) e; return (Fire) e;
break;
} }
} }
return x; return (Fire) items.get(0);
} }
public List<Position> neighbors(Position position) { public List<Position> neighbors(Position position) {
List<Position> list = new ArrayList<>(); List<Position> list = new ArrayList<>();
...@@ -103,16 +105,13 @@ public class Fboard { ...@@ -103,16 +105,13 @@ public class Fboard {
return position; return position;
} }
// A revoir
public List<ModelElement> getState(Position position){ public List<ModelElement> getState(Position position){
List<ModelElement> result = new ArrayList<>(); List<ModelElement> result = new ArrayList<>();
for (item e :items) { for (item e :items) {
if (e.getPositions().contains(position) && e.getID() == 1) { if (e.getPositions().contains(position) && e.getID() == 1) {
result.add(e.getState()); result.add(e.getState());
} }
}
for (item e :items) {
if (e.getPositions().contains(position) && e.getID() == 0) { if (e.getPositions().contains(position) && e.getID() == 0) {
result.add(e.getState()); result.add(e.getState());
} }
......
...@@ -10,7 +10,7 @@ public class Fire implements item { ...@@ -10,7 +10,7 @@ public class Fire implements item {
private final int initialFireCount; private final int initialFireCount;
private List<Position> firePositions; private List<Position> firePositions;
private final ModelElement state; private ModelElement state;
private final Random randomGenerator = new Random(); private final Random randomGenerator = new Random();
private final int ID=1; private final int ID=1;
......
...@@ -7,7 +7,7 @@ import java.util.Random; ...@@ -7,7 +7,7 @@ import java.util.Random;
public class FireFighter extends Extinguisher { public class FireFighter extends Extinguisher {
private final ModelElement state; private ModelElement state;
private List<Position> firefighterPositions; private List<Position> firefighterPositions;
private final Random randomGenerator = new Random(); private final Random randomGenerator = new Random();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment