I have 3 different classes; Contestant, Event and Result.
public class Contestant {
public static ArrayList<Contestant> allContestants = new ArrayList<>();
private int contestantId;
private String firstName;
private String lastName;
public Contestant (int contestantId, String firstName, String lastName) {
this.contestantId = contestantId;
this.firstName = firstName;
this.lastName = lastName;
}
public class Event {
public static ArrayList<Event> allEvents = new ArrayList<>();
private String eventName;
public Event (String eventName) {
this.eventName = eventName;
}
public class Result {
public static ArrayList<Result> allResults = new ArrayList<>();
private double result;
private int attemptNumber;
public Result (double result, int attemptNumber) {
this.result = result;
this.attemptNumber = attemptNumber:
}
The classes have different methods for adding new Contestant objects, new Event objects and new Result objects to each ArrayList. Each contestant can participate in multiple events and for each event they can create multiple results.
What I want to achieve is for each Result object to reference a Contestant ArrayList object as well as an Event ArrayList object - how can I best link them?
ResultListofResultand pass it toEvent, createEventListofEventand pass it toContestent. Outside all these class makeCollectionListofCollection.