Commit 231e73ca authored by Dumoulin Nicolas's avatar Dumoulin Nicolas
Browse files

Constructor with list of farms removed from the Simulator

parent 50f80b87
......@@ -50,27 +50,6 @@ public class Simulator {
this.global = createGlobal();
}
public Simulator(Parameters parameters, List<Farm> farms, List<Farmer> farmers) {
this.parameters = parameters;
this.geoAreas = new ArrayList<>();
// FIXME duplicate farm/farmers in constructor
for (Farm farm : farms) {
for (Patch patch : farm.getPatches()) {
if (!this.geoAreas.contains(patch.getGeoArea())) {
this.geoAreas.add(patch.getGeoArea());
}
}
}
this.farmers = farmers;
this.timestamp = java.time.LocalDateTime.now().toString();
this.dynamicsList = parameters.getDynamics();
this.initIgnoredFields();
for (Dynamics dynamics : dynamicsList) {
dynamics.setTimeStamp(timestamp);
}
this.global = createGlobal();
}
// quick & dirty method to create a global flow aimed to be replaced by a parameterized version by the generator.
public Flow createGlobal() {
Set<Product> productsIn = new HashSet<>();
......
......@@ -48,8 +48,7 @@ public class FarmerTest {
}
Farmer farmer = new Farmer(54, farm);
Simulator simulator = new Simulator(new Parameters(0, new ArrayList<>()), Collections
.singletonList(farm), Collections.singletonList(farmer));
Simulator simulator = new Simulator(new Parameters(0, new ArrayList<>()), Collections.singletonList(farmer));
ByteArrayOutputStream stream = new ByteArrayOutputStream();
simulator.serializeXML(stream);
Simulator simulator2 = Simulator.loadSimulator(new ByteArrayInputStream(stream.toByteArray()));
......
......@@ -45,7 +45,7 @@ public class GeoAreaTest {
farm.addPatch(new Patch(g, 25.3f, CulturalPractice.S, new Product("Chou", Unit.Kg)));
Farmer farmer = new Farmer(30, farm);
Simulator simulator = new Simulator(new Parameters(0, new ArrayList<>()), farms, Arrays.asList(farmer));
Simulator simulator = new Simulator(new Parameters(0, new ArrayList<>()), Arrays.asList(farmer));
ByteArrayOutputStream stream = new ByteArrayOutputStream();
simulator.serializeXML(stream);
Simulator simulator2 = Simulator.loadSimulator(new ByteArrayInputStream(stream.toByteArray()));
......
......@@ -146,7 +146,7 @@ public class SimulatorMinimalTest {
List<Dynamics> dynamics = new ArrayList<>();
dynamics.addAll(Arrays.asList(new PopulationDynamics(), new ProductionDynamics(), new MarketDynamics(),
new FlowDynamics()));
Simulator simulator = new Simulator(new Parameters(0, dynamics), farms, farmers);
Simulator simulator = new Simulator(new Parameters(0, dynamics), farmers);
simulator.serialize("minimal.xml");
directory = simulator.getTimestampDirectory();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment