Class ChanceTable<T>

  • Type Parameters:
    T - The entry type
    All Implemented Interfaces:
    java.lang.Iterable<TableEntry<T>>, java.util.Collection<TableEntry<T>>

    public class ChanceTable<T>
    extends RandomObjectTable<T>
    This is a variant of the RandomObjectTable which uses a 0-1 chance attached to every entry. When rolled the a chance roll is calculated for each entry and all entries which pass are returned.
    • Constructor Detail

      • ChanceTable

        public ChanceTable()
        Creates a new ChanceTable with a default roll count of 1.
      • ChanceTable

        public ChanceTable​(int rolls)
        Creates a new ChanceTable.
        Parameters:
        rolls - The number of rolls to perform
    • Method Detail

      • get

        public java.util.List<T> get​(java.util.Random rand)
        Description copied from class: RandomObjectTable
        Performs a number of rolls according to the number of rolls defined by RandomObjectTable.rolls() and returns items from the table for each roll.
        Specified by:
        get in class RandomObjectTable<T>
        Parameters:
        rand - The random object to use
        Returns:
        The returned items, may be empty but not null
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<T>
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<T>
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object