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

Refactoring

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