Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## things.common.tools
Class Gamer

    java.lang.Object
      things.common.tools.Gamer

Direct Known Subclasses:
  TokenFactory

    public class Gamer

extends java.lang.Object

A general odds tool.

Version:
  1.0

  Version History

      EPG - Rewrite - 10 AUG 06

Author:
  Erich P. Gatejen

Field Summary
`java.util.Random` | `rng` The Random source.

Constructor Summary
`Gamer()` Construct the gamer.

Method Summary
`boolean` | `flipcoin()` Flip a coin, true or false.
`boolean` | `percent(int chance)` A percentage chance.
`java.lang.String` | `pick(java.lang.String[] strings)` Pick one.
`int` | `pickNumber(int[] numbers)` Pick one.
`int` | `range(int lowest, int highest)` A range.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### rng

    public java.util.Random rng

  The Random source. I can't remember why I left it public.

Constructor Detail

### Gamer

    public Gamer()

  Construct the gamer.

Method Detail

### flipcoin

    public boolean flipcoin()

  Flip a coin, true or false.

  Returns:
    true or false, 50/50 chance of either.

### percent

    public boolean percent(int chance)

  A percentage chance.

  Parameters:
    `chance` - the percentage change. 0 is never, 100 is always, and all chances in between. other numbers will always yeild a lose (false).
  Returns:
    true if win (within the percentage range), otherwise false.

### range

    public int range(int lowest,
                     int highest)

  A range. It'll use whatever you give it, even if it yields weird results.

  Parameters:
    `lowest` - lowest number, inclusive
    `highest` - highest number, inclusive.
  Returns:
    the number chosen.

### pick

    public java.lang.String pick(java.lang.String[] strings)

  Pick one.

  Parameters:
    `strings` - an array of Strings.
  Returns:
    the string that we picked of null if the array is null or empty.

### pickNumber

    public int pickNumber(int[] numbers)

  Pick one.

  Parameters:
    `numbers` - an array of int.
  Returns:
    the int that we picked or 0 if the array is null or empty.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Things.