-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFootballLeague.java
More file actions
49 lines (41 loc) · 1.41 KB
/
FootballLeague.java
File metadata and controls
49 lines (41 loc) · 1.41 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
package huongdoituong;
import java.util.ArrayList;
class FootballLeague {
private String name;
private long moneyBonus;
private ArrayList<FootballTeam> ft;
public FootballLeague() {}
public FootballLeague(String name, long moneyBonus, ArrayList<FootballTeam> ft) {
this.name = name;
this.moneyBonus = moneyBonus;
this.ft = ft;
}
public String getName() {
return name;
}
public long getMoneyBonus() {
return moneyBonus;
}
public void display() {
System.out.println("League Name: " + name + ", Money Bonus: " + moneyBonus);
for (FootballTeam team : ft) {
team.display();
}
}
public static ArrayList<FootballLeague> getMaxLeagueTeam(ArrayList<FootballLeague> vt) {
int maxTeams = vt.get(0).ft.size();
// khởi tạo biến maxTeams với số lượng đội trong giải đấu đầu tiên trong danh sách vt
for (FootballLeague league : vt) {
if (league.ft.size() > maxTeams) {
maxTeams = league.ft.size();
}
}
ArrayList<FootballLeague> maxTeamsLeagues = new ArrayList<>();
for (FootballLeague league : vt) {
if (league.ft.size() == maxTeams) {
maxTeamsLeagues.add(league);
}
}
return maxTeamsLeagues;
}
}