Android Open Source - dice-probabilities Constant Current Dice Pile






From Project

Back to project page dice-probabilities.

License

The source code is released under:

MIT License

If you think the Android project dice-probabilities listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.kleemann.diceprobabilities;
//www. j  a v a2 s. c  om
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

/**
 * <p>
 * A special version of the CurrentDicePile that is used to represent constants.
 * In most cases this can be treated like a one sided die but there are a couple
 * differences:
 * 
 * <p>
 * 1. the display is just a number; no "dN" suffix
 * 
 * <p>
 * 2. The button is only made invisible if the control is cleared.  This allows
 * the user to enter negative nubmers.
 */
public class ConstantCurrentDicePile extends CurrentDicePile {

  public ConstantCurrentDicePile(Button button, OnClickListener changed) {
    super(1, button, changed);
  }

  @Override
  protected void updateButton() {
    updateButton(false);
  }

  private void updateButton(boolean clear) {
    button.setText(count < 0 ? Integer.toString(count) : "+" + count);
    button.setVisibility(clear ? View.GONE : View.VISIBLE);
  }

  @Override
  public void setCount(int count) {
    // constant is allowed to be negative
    this.count = count;
    updateButton();
    changed.onClick(button);
  }

  public void clear() {
    this.count = 0;
    updateButton(true);
    changed.onClick(button);
  }
}




Java Source Code List

com.asolutions.widget.RowLayout.java
org.kleemann.diceprobabilities.Check.java
org.kleemann.diceprobabilities.ConstantCurrentDicePile.java
org.kleemann.diceprobabilities.CurrentDicePile.java
org.kleemann.diceprobabilities.DiceSet.java
org.kleemann.diceprobabilities.MainActivity.java
org.kleemann.diceprobabilities.PoolDicePile.java
org.kleemann.diceprobabilities.TargetPool.java
org.kleemann.diceprobabilities.Target.java
org.kleemann.diceprobabilities.distribution.AbstractDistribution.java
org.kleemann.diceprobabilities.distribution.CachedCumulativeDistribution.java
org.kleemann.diceprobabilities.distribution.ConstantDistribution.java
org.kleemann.diceprobabilities.distribution.CritDistribution.java
org.kleemann.diceprobabilities.distribution.DeathZoneDieDistribution.java
org.kleemann.diceprobabilities.distribution.DieDistribution.java
org.kleemann.diceprobabilities.distribution.Distribution.java
org.kleemann.diceprobabilities.distribution.DogslicerDistribution.java
org.kleemann.diceprobabilities.distribution.ScaleCumulativeDistribution.java
org.kleemann.diceprobabilities.distribution.SumDistribution.java
org.kleemann.diceprobabilities.graph.GraphView.java
org.kleemann.diceprobabilities.graph.Interpolate.java
org.kleemann.diceprobabilities.graph.Point.java
org.kleemann.diceprobabilities.graph.Vector.java
org.kleemann.diceprobabilities.special.AbstractSpecial.java
org.kleemann.diceprobabilities.special.CritSpecial.java
org.kleemann.diceprobabilities.special.DeathZoneSpecial.java
org.kleemann.diceprobabilities.special.DogslicerSpecial.java
org.kleemann.diceprobabilities.special.FailureSpecial.java
org.kleemann.diceprobabilities.special.ForcedRerollSpecial.java
org.kleemann.diceprobabilities.special.ModifyEachDieSpecial.java
org.kleemann.diceprobabilities.special.NormalSpecial.java
org.kleemann.diceprobabilities.special.SecondChanceSpecial.java
org.kleemann.diceprobabilities.special.SpecialSpinner.java
org.kleemann.diceprobabilities.special.Special.java