Class RandomWithDuplicates

java.lang.Object
edu.gvsu.kurmasz.warszawa.listgen.IntegerListGenerator
edu.gvsu.kurmasz.warszawa.listgen.RandomWithDuplicates
Direct Known Subclasses:
RandomWithoutDuplicates

public class RandomWithDuplicates
extends IntegerListGenerator
Generate lists of random integers within a specified range. Note: generateLongArray is not yet implemented for values outside of an integer range.
Author:
Zachary Kurmas
  • Constructor Summary

    Constructors 
    Constructor Description
    RandomWithDuplicates()
    Default constructor.
    RandomWithDuplicates​(java.util.Random rin)
    Constructor allowing user to specify which java.util.Random object to use.
  • Method Summary

    Modifier and Type Method Description
    int[] generateIntArray​(int min, int max, int amount)
    Generate an array of amount random integers containing the values between min and max (inclusive).
    long[] generateLongArray​(long min, long max, long amount)
    Generate an array of random long integers containing the values between start and stop (inclusive) --- parameters must be in an integer range.

    Methods inherited from class edu.gvsu.kurmasz.warszawa.listgen.IntegerListGenerator

    generateIntList, generateLongList

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RandomWithDuplicates

      public RandomWithDuplicates​(java.util.Random rin)
      Constructor allowing user to specify which java.util.Random object to use.
      Parameters:
      rin - the desired java.util.Random object.
    • RandomWithDuplicates

      public RandomWithDuplicates()
      Default constructor. Generates a new Random object.
  • Method Details

    • generateLongArray

      public long[] generateLongArray​(long min, long max, long amount)
      Generate an array of random long integers containing the values between start and stop (inclusive) --- parameters must be in an integer range.
      Specified by:
      generateLongArray in class IntegerListGenerator
      Parameters:
      min - the minimum value that may appear. For now, Integer.MIN_VALUEminInteger.MAX_VALUE.
      max - the maximum value that may appear. For now, Integer.MIN_VALUEminInteger.MAX_VALUE. Also, max <= min + Integer.MAX_VALUE.
      amount - the number of integers to generate. Must be >= 1 and < Integer.MAX_VALUE.
      Returns:
      an array of long integers.
      Throws:
      java.lang.IllegalArgumentException - if the parameters specify an array that is too large, or if any of the parameters is out of range.
    • generateIntArray

      public int[] generateIntArray​(int min, int max, int amount)
      Generate an array of amount random integers containing the values between min and max (inclusive).
      Overrides:
      generateIntArray in class IntegerListGenerator
      Parameters:
      min - the minimum value that may appear
      max - the maximum value that may appear. Must be >= min and <= (min + Integer.MAX_VALUE)
      amount - the number of integers to generate. Must be >= 1.
      Returns:
      an array of integers.
      Throws:
      java.lang.IllegalArgumentException - if the parameters specify an array that is too large.