← back to the schedule


Tournament Brackets PROJECT
By Alyce Brady




PROBLEM DESCRIPTION

In this project you will implement a program to read tournament participants (for example, tennis players or basketball teams) in from a file along with their rankings, print that information sorted by ranking, and determine initial match-ups. In general, match-ups pair the highest-ranked participant with the lowest-ranked participant, the second highest-ranked participant with the second lowest-ranked participant, and so on.

If the number of participants is not an even power of two, then there will be an initial round involving only some participants in order to get the number of match-ups to an even power of 2; the highest-ranked participants will have a bye for the first round. The second round would then have a full complement of participants. For example, if there are 68 teams in a tournament, the first round (the bye round would consist of only the 8 lowest-ranked teams, with the other 60 teams having a bye for the first round. The four winners of the bye round would then join the other 60 teams for a full round of 64 teams participating in 32 matches. In a less-realistic but shorter example of a tournament with 3 participating teams, the top-ranked team would have a bye for the first round and would then play the winner of the other two teams. The table below compares this scenario agains a single match-up between 2 teams with no bye.

Example with ByesExample with no Byes
Initial Rankings:
1. S Carolina
2. UConn
3. UCLA

Number of Rounds: 2
Number of Byes: 1

First-Round Byes:
1. S Carolina
----------------
Round 1 Match-Ups:
2. UConn vs. 3. UCLA

Round 1 Scores:
2. UConn (78) vs. 3. UCLA (64)
----------------
Round 2 Match-Ups:
1. S Carolina vs. 2. UConn

Round 2 Scores:
2. UConn (82) vs. 1. S Carolina (59)
Initial Rankings:
1. S Carolina
2. UConn

Number of Rounds: 1
Number of Byes: 0
----------------
Round 1 Match-Ups:
1. S Carolina vs. 2. UConn

Round 1 Scores:
2. UConn (82) vs. 1. S Carolina (59)

Getting Started

Most of the functionality for the Tournament program is in the Tournament class, although there are several other classes that represent participant information as (name, value) pairs, match-up assignments between participants, and classes that know how to read those values from files.

Download the files for the Tournament Brackets Project:

  • Tournament.java — Contains most of the functionality of the program, including the main method. (Needs to be completed.)
  • ParticipantInfo.java — Represents (name, value) information about participants, such as their name and ranking. (Fully implemented)
  • ParticipantReader.java — An object that knows how to read participant information from a file, one participant per line. (Fully implemented)
  • Matchup.java — Represents a pairing of two participants and their scores. (Fully implemented)
  • MatchupReader.java — An object that knows how to read participant information from a file, two participants per line. (Needs to be completed.)
  • ValidatedInputReader.java — Class with static methods that can prompt users for numeric or string input. (Fully implemented)
  • There are two files containing sample rankings data: 18rankings.txt (18 participants, so byes are needed) and 16rankings.txt (16 participants, so no byes necessary).
  • There are two files containing sample score results: byeRoundScores.txt and fullRoundScores.txt.

The Tournament class follows the Template Method pattern, with high-level methods breaking their tasks down and calling lower-level methods to complete those tasks. For example:

    The runTournament method calls
        reportRankings,
        setRoundsAndByes, and
        runByeRound,
        and will call others when completed.
    The runByeRound method calls
        determineMatchups,
        printMatchups, and
        reportScores.

The incomplete Tournament class provided to you contains the general structure of the class and some of the detailed code (especially the code related to reading in information from files), but also has code missing and other code commented out.


First Look: Reading and Running Code for Understanding

Start by reading the code, but don't try to read every detail at once. The Tournament class contains the main method at the bottom of the class -- what does it do? Where is the runTournament method? In general, (leaving main aside), are the methods laid out in a top-down or a bottom-up fashion?

Does the Tournament class have many instance variables that are shared among all of the methods? One of the first methods that the runTournament method calls is reportRankings. Are the rankings only used within reportRankings, or are they communicated back to runTournament, and if so, how?

Before diving deeply into all the details of the Tournament class, glance at the 18rankings.txt file and round2Scores.txt to see what the format is of the data being used by the program. Run the program to see what it does with the data. Look back at Tournament and notice which blocks of code are commented-out and which are not -- does the initial behavior of the code make sense based on your initial look at the runTournament method?


Making Modifications

Following the precepts and practices of Agile Development, you should start by making the smallest modifications you can, and test them before going on to other modifications. As you work on the program, your output should slowly look more and more like that in the Sample Output below.

You may complete the implementation of the Tournament and MatchupReader classes based only on the comments in the existing code and the Sample Output as a guide, or, if you prefer more detailed guidance, you may follow the guided directions provided here.


Guided Directions

(Display)


Sample Output

(Display)


Clean and Refactor

Follow this link to clean and refactor your comments and code.


Submission

Submit your completed program through Kit, under Tournament Brackets Project.

Have fun! And if you have any questions remember I am available during office hours and the Collaboration Center folks are here for you as well!




← back to the schedule