Skip to content
Snippets Groups Projects
Commit 8edf2f80 authored by ousseyn01's avatar ousseyn01
Browse files

Cloud.java is DONE

parent 8f449f89
No related branches found
No related tags found
No related merge requests found
package model; package model;
import util.Position;
import java.util.*;
import java.util.Map;
public class Cloud { public class Cloud {
private Position position;
private final Map<Position, List<Position>> neighbors;
private final Random randomGenerator = new Random();
public Cloud(Position startPosition, Map<Position, List<Position>> neighbors) {
this.position = startPosition;
this.neighbors = neighbors;
}
public Position getPosition() {
return position;
}
public void moveRandomly() {
List<Position> adjacentPositions = neighbors.get(position);
position = adjacentPositions.get(randomGenerator.nextInt(adjacentPositions.size()));
}
public void extinguishFire(Fire fire) {
if (fire.getFirePositions().contains(position)) {
fire.getFirePositions().remove(position);
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment