<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/** A TrickDice has one weightedSide such that the
 *  weightedSide appears weight times as often as other sides
 */
class TrickDice extends Dice {
  
  private int weightedSide;  //Weighted side appears more often
  private int weight;        //Weighted side appears weight
                             //  times as often as other sides

  /** TrickDice has side s appearing with weight w */
  public TrickDice(int numFaces, int s, int w) {
    super(numFaces);
    weightedSide= s;
    weight= w;
  }

  /** = Get weighted side */
  public int getWSide() { return weightedSide; }
  
  /** = Get weight of weighted side */
  public int getWeight() { return weight; }

  /** top gets random value in 1..sides given trick property */
  public void roll() {
    int r= randInt(1,(getSides()+weight-1));
    if (r&gt;getSides())
      setTop(weightedSide);
    else
      setTop(r);
  }
 
  /** = String description of this TrickDice */
  public String toString() {
    return "Tricky " + super.toString();
  }
}
</pre></body></html>