-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
80 lines (46 loc) · 2.28 KB
/
Main.java
File metadata and controls
80 lines (46 loc) · 2.28 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
package com.sayantandas;
public class Main {
/**
* ArrayList<Team> teams;
* Collections.sort(teams);
* Create a generic class to implement a league table for a sport.
* The class should allow teams to be added to the list, and store
* a list of teams that belong to the league.
* Your class should have a method to print out the teams in order,
* with the team at the top of the league printed first.
* Only teams of the same type should be added to any particular
* instance of the league class - the program should fail to compile
* if an attempt is made to add an incompatible team.
*/
public static void main(String[] args) {
League<Team<FootballPlayer>> footballLeague = new League<>("AFL");
Team<FootballPlayer> adelaideCrows = new Team<>("Adelaide Crows");
Team<FootballPlayer> melbourne = new Team<>("Melbourne");
Team<FootballPlayer> hawthorn= new Team<>("Hawthorn");
Team<FootballPlayer> fremantle= new Team<>("Fremantle");
Team<BaseballPlayer> baseballTeam = new Team<>("Chicago Cubs");
hawthorn.matchResult(fremantle, 1, 0);
hawthorn.matchResult(adelaideCrows, 3, 8);
adelaideCrows.matchResult(fremantle, 2, 1);
footballLeague.add(adelaideCrows);
footballLeague.add(melbourne);
footballLeague.add(hawthorn);
footballLeague.add(fremantle);
// footballLeague.add(baseballTeam);
footballLeague.showLeagueTable();
BaseballPlayer pat = new BaseballPlayer("Pat");
SoccerPlayer beckham = new SoccerPlayer("Beckham");
Team rawTeam = new Team("Raw Team");
rawTeam.addPlayer(beckham); // unchecked warning
rawTeam.addPlayer(pat); // unchecked warning
footballLeague.add(rawTeam); // unchecked warning
League<Team> rawLeague = new League<>("Raw");
rawLeague.add(adelaideCrows); // no warning
rawLeague.add(baseballTeam); // no warning
rawLeague.add(rawTeam); // no warning
League reallyRaw = new League("Really raw");
reallyRaw.add(adelaideCrows); // unchecked warning
reallyRaw.add(baseballTeam); // unchecked warning
reallyRaw.add(rawTeam); // unchecked warning
}
}