Commit 65fd7bc0 authored by Jakob Schöttl's avatar Jakob Schöttl
Browse files

Bugfix: half-compartments were not considered

parent 3bc99890
......@@ -110,7 +110,7 @@ public class SeatingModel implements ActiveCallback, Model {
private void assignSeatTarget(Pedestrian p) {
final Compartment compartment = trainModel.getCompartment(p);
if (compartment.getPersonCount() == Compartment.MAX_PERSONS_PER_COMPARTMENT) {
if (compartment.isFull()) {
logDebug("Compartment %d is full. No seat available for pedestrian %d.",
compartment.getIndex(), p.getId());
proceedToNextCompartmentIfPossible(p);
......
......@@ -88,4 +88,12 @@ public class Compartment {
return getSeatGroups().stream().mapToInt(SeatGroup::getPersonCount).sum();
}
public boolean isFull() {
for (SeatGroup sg : seatGroups) {
if (!sg.isFull())
return false;
}
return true;
}
}
Markdown is supported
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