Skip to content
Snippets Groups Projects
Commit 05895e3b authored by ASFOUR Mohamed's avatar ASFOUR Mohamed
Browse files

rajout des getter et setter dans FireFighter et Fire A.M

parent b9dbcaec
Branches
No related tags found
No related merge requests found
Pipeline #38155 failed
...@@ -10,4 +10,11 @@ public class Fire { ...@@ -10,4 +10,11 @@ public class Fire {
public Fire(Position position){ public Fire(Position position){
this.firePositions = position; this.firePositions = position;
} }
public Position getFirePositions(){
return this.firePositions;
}
public void setFirePositions(Position firePositions){
this.firePositions = firePositions;
}
} }
...@@ -10,6 +10,13 @@ public class FireFighter { ...@@ -10,6 +10,13 @@ public class FireFighter {
public FireFighter(Position firefighterPositions) { public FireFighter(Position firefighterPositions) {
this.firefighterPositions = firefighterPositions; this.firefighterPositions = firefighterPositions;
} }
public void setFirefighterPositions(Position firefighterPositions) {
this.firefighterPositions = firefighterPositions;
}
public Position getFirefighterPositions() {
return firefighterPositions;
}
} }
...@@ -43,9 +43,9 @@ public class FirefighterBoard implements Board<List<ModelElement>> { ...@@ -43,9 +43,9 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
firefighter= new ArrayList<>(); firefighter= new ArrayList<>();
fire = new HashSet<>(); fire = new HashSet<>();
for (int index = 0; index < initialFireCount; index++) for (int index = 0; index < initialFireCount; index++)
fire.add(randomPosition()); fire.add(new Fire(randomPosition()));
for (int index = 0; index < initialFirefighterCount; index++) for (int index = 0; index < initialFirefighterCount; index++)
firefighter.add(randomPosition()); firefighter.add(new FireFighter(randomPosition()));
} }
private Position randomPosition() { private Position randomPosition() {
...@@ -55,10 +55,10 @@ public class FirefighterBoard implements Board<List<ModelElement>> { ...@@ -55,10 +55,10 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
@Override @Override
public List<ModelElement> getState(Position position) { public List<ModelElement> getState(Position position) {
List<ModelElement> result = new ArrayList<>(); List<ModelElement> result = new ArrayList<>();
for (Position firefighterPosition : firefighterPositions) for (FireFighter firefighter : firefighter)
if (firefighterPosition.equals(position)) if (firefighter.getFirefighterPositions().equals(position))
result.add(ModelElement.FIREFIGHTER); result.add(ModelElement.FIREFIGHTER);
if (firePositions.contains(position)) if (fire.contains(position))
result.add(ModelElement.FIRE); result.add(ModelElement.FIRE);
return result; return result;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment