-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestWeekObject.java
More file actions
63 lines (45 loc) · 2.15 KB
/
Copy pathtestWeekObject.java
File metadata and controls
63 lines (45 loc) · 2.15 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
import java.util.ArrayList;
public class testWeekObject {
public static void main(String[] args) {
WeekObject testWeek = new WeekObject();
int testWeekNumber = testWeek.getWeek();
TeamObject teamOne = new TeamObject("Team1");
TeamObject teamTwo = new TeamObject("Team2");
TeamObject teamThree = new TeamObject("TeamThree");
TeamObject teamFour = new TeamObject("TeamFour");
testWeek.newMatch(teamOne, teamTwo);
testWeek.newMatch(teamThree, teamFour);
int currentSize = testWeek.getMatchesSize();
System.out.println("Get ready for these week " + testWeekNumber + " matches!\nThere are " + currentSize + " total matches!");
ArrayList<TeamObject> findMatch = testWeek.getMatch("Team1");
System.out.println("Upcoming Match: " + declareSingleMatch(findMatch));
ArrayList<TeamObject> matches = testWeek.getAllMatches();
System.out.println("Here are this weeks matches: " + declareAllMatches(matches));
testWeek.cancelMatch("TeamThree");
ArrayList<TeamObject> updatedMatches = testWeek.getAllMatches();
System.out.println("Here is the updated matches: " + declareAllMatches(updatedMatches));
WeekObject testWeekTwo = new WeekObject(2);
System.out.println("Be sure to look our for upcoming week" + testWeekTwo.getWeek() + "!!!");
}
public static String declareSingleMatch(ArrayList<TeamObject> match)
{
String declaration = "";
String firstTeam = match.get(0).getName();
String secondTeam = match.get(1).getName();
declaration = String.format("%s vs %s ", firstTeam, secondTeam);
return declaration;
}
public static String declareAllMatches(ArrayList<TeamObject> match)
{
String declaration = "";
for(int i = 0; i < match.size() - 1; i++)
{
ArrayList<TeamObject> currentMatch = new ArrayList<>();
currentMatch.add(match.get(i));
currentMatch.add(match.get(i+1));
declaration += declareSingleMatch(currentMatch);
i++;
}
return declaration;
}
}