package pas.multiset;

import java.util.Random;

/**
 * Class for simulating dice rolls and experimentally exploring distributions of roll totals.
 *
 * @author ???
 * @version ???
 *
 */
public class Roller {

  private Random rand;

  /**
   * Create a roller with a specified seed for reproducible results.
   *
   * @param seed Seed for random number generator
   */
  public Roller(long seed) {
    rand = new Random(seed);
  }

  /**
   * Create a roller with a system-assigned seed.
   */
  public Roller() {
    rand = new Random();
  }

  /**
   * Roll the indicated type of dice the indicated number of times and return the sum of all rolls.
   *
   * @param numDice Number of dice to roll
   * @param numSides Number of sides for each die
   * @return The sum of all dice rolls
   * @throws IllegalArgumentException if numDice or numDice are not positive
   */
  public int roll(int numDice, int numSides) {
    // TODO
    
    int sum = 0;
    for (int i = 0; i < numDice; i++) {
      sum += rand.nextInt(numSides) + 1; // For each die, roll and add to sum
    }
    return sum;
  }

  /**
   * This method repeatedly performs multi-dice rolls and keeps a running tally of the number of
   * times that each total is observed.
   *
   * @param numTrials Number of times to roll the indicated set of dice
   * @param numDice The number of dice to roll in each trial
   * @param numSides The number of sides for the dice
   * @return A Multiset of total values indicating the number of times that each total occurred
   * @throws IllegalArgumentException if numTrials, numDice, or numSides are not positive
   */
  public Multiset<Integer> multiRoll(int numTrials, int numDice, int numSides) {
    return null; // TODO
  }

  /**
   * Plot an ASCII histogram illustrating the distribution of totals observed over multiple rolls.
   *
   * @param numTrials Number of times to roll the indicated set of dice
   * @param numDice The number of dice to roll in each trial
   * @param numSides The number of sides for the dice
   * @param scale How many results will be represented by each hash mark. For example, if scale is
   *        equal to 10, then each hash mark represents 10 outcomes, rounding down. For example, if
   *        scale is 10 and there are 29 occurrences, then one two hash marks will be displayed.
   * @throws IllegalArgumentException in the case of any non-positive argument
   */
  public void plotRolls(int numTrials, int numDice, int numSides, int scale) {
    // TODO
  }


}
