-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeekObject.java
More file actions
158 lines (127 loc) · 3.59 KB
/
Copy pathWeekObject.java
File metadata and controls
158 lines (127 loc) · 3.59 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import java.util.ArrayList;
public class WeekObject {
private int week;
private ArrayList<TeamObject> matches;
private ArrayList<TeamObject> vsMatches;
public WeekObject()
{
this.week = 1;
matches = new ArrayList<TeamObject>();
vsMatches = new ArrayList<TeamObject>();
}
public WeekObject(int week)
{
this.week = week;
matches = new ArrayList<TeamObject>();
vsMatches = new ArrayList<TeamObject>();
}
public int getWeek()
{
return week;
}
public int getMatchesSize()
{
return matches.size();
}
public void newMatch(TeamObject team, TeamObject teamTwo)
{
matches.add(team);
vsMatches.add(teamTwo);
}
public ArrayList<TeamObject> getMatch(String teamName)
{
boolean retrieved = false;
ArrayList<TeamObject> match = new ArrayList<>();
for(int i = 0; i < matches.size(); i++)
{
if(matches.get(i).getName().equals(teamName))
{
retrieved = true;
match.add(matches.get(i));
match.add(vsMatches.get(i));
}
}
for(int i = 0; i < vsMatches.size(); i++)
{
if(retrieved)
{
break;
}
if(vsMatches.get(i).getName().equals(teamName))
{
retrieved = true;
match.add(matches.get(i));
match.add(vsMatches.get(i));
}
}
if(!retrieved)
{
//error?
}
return match;
}
public void cancelMatch(String teamName) //find team in either list. remove corrosponding team from other list
{
boolean canceled = false;
for(int i = 0; i < matches.size(); i++)
{
if(matches.get(i).getName().equals(teamName))
{
canceled = true;
vsMatches.remove(i);
matches.remove(i);
return;
}
}
for(int i = 0; i < vsMatches.size(); i++)
{
if(vsMatches.get(i).getName().equals(teamName))
{
canceled = true;
matches.remove(i);
vsMatches.remove(i);
return;
}
}
if(!canceled)
{
//error?
}
}
public ArrayList<TeamObject> getAllMatches()
{
ArrayList<TeamObject> weekMatches = new ArrayList<>();
for(int i = 0; i < matches.size(); i++)
{
weekMatches.add(matches.get(i));
weekMatches.add(vsMatches.get(i));
}
return weekMatches;
}
}
/*
weekObject();
- brand new schedule with week as 1
- Empty ArrayList
WeekObject(int week)
- new week
- empty arraylist
- week is set on creation
getWeek()
- returns the week
getMatchesSize()
- returns the number of matches in the given week
newMatch(String teamName, String teamNameTwo)
- input two teams into method
- add them into their respective arraylist
getMatch(String teamName)
- Search for a team
- returns that team and the team they are matched with in an arraylist
cancelMatch(String teamName)
- search for a team
- remove that team as well as the team they were matched with
getAllMatches()
- appends every match into a single arraylist
- i is first team, i+1 is the team they are matched with
- returns an arraylist
*/