This repository was archived by the owner on Mar 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatchList.java
More file actions
62 lines (54 loc) · 1.27 KB
/
Copy pathMatchList.java
File metadata and controls
62 lines (54 loc) · 1.27 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* Defines an object representing an array
* of Match objects
* @author Adam John Campbell Murray
*
*/
public class MatchList
{
/* Instance variables */
private Match [] matchArray; // array of all matches
private int elementsInArray; // number of matches allocated already
/* Class constants */
/** The maximum number of matches the program allows */
private final int MAX_MATCHES = 52; // only one match per week
/**
* Default constructor for the MatchList class.
*/
public MatchList()
{
// initialise number of array elements to zero
elementsInArray = 0;
// create array of matches, initialise each entry to null
matchArray = new Match[MAX_MATCHES];
for (int i = 0; i < MAX_MATCHES; i++)
matchArray[i] = null;
}
/**
* Adds a match to the match array at the next available
* position.
* @param m - the Match object being added
*/
public void addMatchToList(Match m)
{
// adds new match in order of allocation
// instead of week (for output to file)
matchArray[elementsInArray] = m;
elementsInArray++;
}
/*
* Getters and Setters
*/
public Match[] getMatchArray()
{
return matchArray;
}
public Match getMatchArrayAtX(int x)
{
return matchArray[x];
}
public int getElementsInArray()
{
return elementsInArray;
}
}