Skip to content

Commit

Permalink
house keeping
Browse files Browse the repository at this point in the history
  • Loading branch information
pfichtner committed Oct 7, 2023
1 parent 2900e43 commit dabad6f
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions core/src/main/java/org/ase/fourwins/season/Season.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@

public class Season<T> {

private static final class ReversedRound<T> extends Round<T> {

private ReversedRound(List<T> teams) {
super(teams);
}

@Override
protected Matchday<T> matchday(List<T> teams) {
return new ReversedMatchday<T>(teams);
}

}

private static final class ReversedMatchday<T> extends Matchday<T> {

private ReversedMatchday(List<T> teams) {
Expand All @@ -18,23 +31,20 @@ private ReversedMatchday(List<T> teams) {

@Override
protected Match<T> makeMatch(int offset) {
Match<T> pair = super.makeMatch(offset);
return new Match<T>(pair.getTeam2(), pair.getTeam1());
Match<T> match = super.makeMatch(offset);
return new Match<T>(match.getTeam2(), match.getTeam1());
}

}

@Getter
private final Round<T> firstRound, secondRound;

public Season(List<T> teams) {
verifySizeIsEven(teams);
this.firstRound = new Round<T>(teams);
this.secondRound = new Round<T>(teams) {
@Override
protected Matchday<T> matchday(List<T> teams) {
return new ReversedMatchday<T>(teams);
}
};
List<T> unmodifableTeams = List.copyOf(teams);
verifySizeIsEven(unmodifableTeams);
this.firstRound = new Round<T>(unmodifableTeams);
this.secondRound = new ReversedRound<T>(unmodifableTeams);
}

private void verifySizeIsEven(Collection<T> teams) {
Expand Down

0 comments on commit dabad6f

Please sign in to comment.