lajdlksadlmla
[rmh3093.git] / lab5 / Tournament.java
blob5aefd19d6b9eb0a67e75c866b3405f2b09d85c4c
1 /*
2 * Tournament.java
4 * Version:
5 * $Id: Tournament.java,v 1.1 2006/01/20 21:32:33 vcss232 Exp $
7 * Revisions:
8 * $Log: Tournament.java,v $
9 * Revision 1.1 2006/01/20 21:32:33 vcss232
10 * Initial revision
12 * Revision 1.3 2005/01/12 13:27:40 vcss232
13 * revised constant comment
15 * Revision 1.2 2005/01/12 13:17:26 vcss232
16 * corrected comments; switched constant from private to public
18 * Revision 1.1 2005/01/11 18:38:26 vcss232
19 * Initial revision
24 import java.io.*;
26 /**
27 * This class provides a simple test program that takes one command line
28 * argument representing the number of teams in a league. If the program
29 * confirms that the number of teams is greater than 2 and less than or
30 * equal to the maximum allowed and also that the number of teams is a
31 * power of 2, then it invokes a TournamentMaker object and generates the
32 * match-ups for the first round in a round-robin style tournament;
33 * otherwise, an error message is printed on standard error and the
34 * program terminates.
36 * @author Hank Etlinger
39 public class Tournament {
41 /**
42 * maximum number of teams permitted in a tournament; currently
43 * set to 64
45 public static final int MAX_TEAMS = 64;
47 /**
48 * actual number of teams entered in this tournament
50 private static int numberOfTeams;
52 /**
53 * The main program.
55 * @param args command line arguments
57 * @exception IOException may have propagated back from
58 * TournamentMaker
60 public static void main(String[] args ) throws IOException {
62 numberOfTeams = Integer.parseInt( args[ 0 ] );
63 if ( numberOfTeams < MAX_TEAMS && ( numberOfTeams == 4 ||
64 numberOfTeams == 8 ||
65 numberOfTeams == 16 ||
66 numberOfTeams == 32 ||
67 numberOfTeams == 64 ) ) {
68 TournamentMaker tournament = new TournamentMaker();
69 tournament.make( numberOfTeams );
70 } else {
71 System.err.print( "Number of teams must be > 2 and <= " + MAX_TEAMS );
72 System.err.println( " and be a power of 2." );