summaryrefslogtreecommitdiff
path: root/src/main/java/design/model/StrokeLeague.java
blob: f09cabfc53a5cab7c644a99a879e467dfa931525 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package design.model;

import com.fasterxml.jackson.annotation.JsonCreator;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class StrokeLeague extends League {
    private final List<Golfer> participants;

    @JsonCreator
    private StrokeLeague(int id, String name, Date registrationDate, Date startDate, Date endDate, Golfer owner, List<Golfer> participants, List<Match> schedule) {
        super(id, name, registrationDate, startDate, endDate, owner, schedule);
        this.participants = participants;
    }

    public StrokeLeague(String name, Date registrationDate, Date startDate, Date endDate, Golfer owner) {
        super(name, registrationDate, startDate, endDate, owner);
        this.participants = new ArrayList<>();
    }

    public boolean addParticipants(Golfer e) {
        return participants.add(e);
    }

    public boolean removeParticipants(Golfer o) {
        return participants.remove(o);
    }

    public Golfer[] getParticipants() {
        return participants.toArray(Golfer[]::new);
    }
}