/* A BagOfDice is an array of Dice */
class BagOfDice{
  private Dice[] dice;
  
  /* This BagOfDice has numDice 6-sided Dice */ 
  public BagOfDice(int numDice){
    dice = new Dice[numDice];
    for(int i=0; i<numDice; i++)
      dice[i] = new Dice(6);
  }
  
  /* This BagOfDice has n Dice where n is numSides.length and 
   * numSides[i] is the number of sides of the ith Dice
   */ 
  public BagOfDice(int[] numSides){
    dice = new Dice[numSides.length];
    for(int i=0; i<numSides.length; i++)
      dice[i] = new Dice(numSides[i]);
  }
  
  /* =sum of the top faces shown of all Dice in this BagOfDice after
   * all the Dice are rolled
   */ 
  public int rollAllDice(){
    int sum = 0;
    for(int i=0; i<dice.length; i++){
      dice[i].roll();
      sum += dice[i].getTop();
    }
    return sum;
  }
  
  /* =probability that the sum of the outcomes of rolling all
   * Dice in this BagOfDice is equal to SUM
   */
  public double prob(int sum){
    int n = 0;
    for(int i=0; i<10000; i++){
      if(rollAllDice() == sum)
        n++;
    }
    return (double) n / 10000;
  }
}
