-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestSchedule.java
More file actions
61 lines (49 loc) · 2.31 KB
/
Copy pathtestSchedule.java
File metadata and controls
61 lines (49 loc) · 2.31 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
import java.util.ArrayList;
public class testSchedule {
public static void main(String[] args) {
ScheduleObject schedule = new ScheduleObject();
schedule.setName("Summer Tourney");
System.out.printf("Welcome to the %s!%n", schedule.getName());
schedule.addWeek(1);
schedule.addWeek(2);
schedule.addWeek(3);
schedule.addWeek(4);
schedule.addWeek(5);
schedule.addWeek(6);
schedule.addWeek();
System.out.printf("Week %d is currently has %d matches.%n", schedule.getWeek(7).getWeek(), schedule.getWeek(7).getMatchesSize());
System.out.printf("This tourney will span a total of %d weeks!%n", schedule.getTotalWeeks());
schedule.removeWeek(6);
System.out.printf("A week was removed. There are now %d weeks!%n%n", schedule.getTotalWeeks());
System.out.printf("Let's take a took at the week %d matches!%n", schedule.getWeek(4).getWeek());
TeamObject teamOne = new TeamObject("Team1");
TeamObject teamTwo = new TeamObject("Team2");
TeamObject teamThree = new TeamObject("TeamThree");
TeamObject teamFour = new TeamObject("TeamFour");
schedule.getWeek(4).newMatch(teamOne, teamTwo);
schedule.getWeek(4).newMatch(teamThree, teamFour);
System.out.printf("There are %d matches for week %d!%n", schedule.getWeek(4).getMatchesSize(), schedule.getWeek(4).getWeek());
System.out.printf("The matches for this week are as follows: %s%n", declareAllMatches(schedule.getWeek(4).getAllMatches()));
}
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;
}
}