summaryrefslogtreecommitdiffstats
path: root/Algorithms/Part-II/3-BaseballElimination/BaseballElimination.java
blob: 3021da695ab5f43f27f43662bb3d7f51ce534157 (plain)
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
/* vim: set expandtab tabstop=4 shiftwidth=4 : */

public class BaseballElimination
{
    public BaseballElimination(String filename)
    {
        // create a baseball division from given filename in format specified below
    }
    public int numberOfTeams()
    {
        // number of teams
        return 0;
    }
    public Iterable<String> teams()
    {
        // all teams
        return null;
    }
    public int wins(String team)
    {
        // number of wins for given team
        return 0;
    }
    public int losses(String team)
    {
        // number of losses for given team
        return 0;
    }
    public int remaining(String team)
    {
        // number of remaining games for given team
        return 0;
    }
    public int against(String team1, String team2)
    {
        // number of remaining games between team1 and team2
        return 0;
    }
    public boolean isEliminated(String team)
    {
        // is given team eliminated?
        return false;
    }
    public Iterable<String> certificateOfElimination(String team)
    {
        // subset R of teams that eliminates given team; null if not eliminated
        return null;
    }

    public static void main(String[] args) {
        BaseballElimination division = new BaseballElimination(args[0]);
        for (String team : division.teams()) {
            if (division.isEliminated(team)) {
                StdOut.print(team + " is eliminated by the subset R = { ");
                for (String t : division.certificateOfElimination(team))
                    StdOut.print(t + " ");
                StdOut.println("}");
            }
            else {
                StdOut.println(team + " is not eliminated");
            }
        }
    }
}