/**
 * Class for simulating large numbers of volleyball games and comparing
 * statistics on rally and sideout scoring.
 *   @author Dave Reed
 *   @version 10/25/09
 */
public class VolleyballStats {
    public int numGames;
    public int numPoints;
    
    /**
     * Constructs a VolleyballStats object.
     */
    public VolleyballStats(int games, int points) {
        this.numGames = games;
        this.numPoints = points;
    }

    /**
     * Simulates repeated volleyball games between teams with
     *   the specified power rankings, and displays statistics.
     *   @param rank1 the power ranking (0..100) of team 1
     *   @param rank2 the power ranking (0..100) of team 2
     */
    public void playGames(int rank1, int rank2) {
        VolleyballSim matchup = new VolleyballSim(rank1, rank2);
        
        int team1Wins = 0;
        for (int i = 0; i < this.numGames; i++) {
            if (matchup.playGame(this.numPoints) == 1) {
                team1Wins++;
            }
        }
        
        System.out.println("Assuming (" + rank1 + "-" + rank2 +
                           ") rankings over " + this.numGames + 
                           " games to " + this.numPoints + ":");
        System.out.println("  team 1 winning percentage:  " +
                           100.0*team1Wins/this.numGames + "%"); 
        System.out.println();
    }
}