Commit 2be636de authored by Jakob Schöttl's avatar Jakob Schöttl
Browse files

Refactoring

parent bb7d5bef
......@@ -28,12 +28,7 @@ public class Compartment {
this.targetSeatMap = targetSeatMap;
seatGroups = new ArrayList<>(4);
final int nSeatGroups;
if (isHalfCompartment()) {
nSeatGroups = 2;
} else {
nSeatGroups = 4;
}
final int nSeatGroups = isHalfCompartment() ? 2 : 4;
addCompartment(nSeatGroups);
}
......
......@@ -38,7 +38,7 @@ public class SeatGroup {
final int compartmentIndex = compartment.getIndex();
final int longRowIndex1, longRowIndex2;
if (isInLeftRow()) {
if (isAtLeftSide()) {
longRowIndex1 = 0;
longRowIndex2 = 1;
} else {
......@@ -69,10 +69,6 @@ public class SeatGroup {
}
private boolean isInLeftRow() {
return index % 2 == 0; // even -> left row
}
public Seat getSeat(int index) {
return seats.get(index);
}
......@@ -173,7 +169,7 @@ public class SeatGroup {
public Seat availableSeatAtSide(SeatSide side) {
int[] indexes;
if (isInLeftRow()) {
if (isAtLeftSide()) {
if (side == SeatSide.WINDOW) {
indexes = new int[] {0, 2};
} else {
......@@ -224,4 +220,8 @@ public class SeatGroup {
return getPersonCount() == SEATS_PER_SEAT_GROUP;
}
public boolean isAtLeftSide() {
return index % 2 == 0;
}
}
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