java.lang.Object
com.github.freddyyj.randomtrainsimworld.Random

public class Random
extends Object
Random picker class.

Extend this class and call MainController.setRandom(Random) to change your custom random class. This class should be singleton.

Author:
FreddyYJ_
  • Constructor Details

    • Random

      protected Random()
      Constructor
  • Method Details

    • getInstance

      public static Random getInstance()
      Get instance of this class.
      Returns:
      Random
    • randomRoute

      public Route randomRoute​(ArrayList<Route> routes)
      Pick random route.

      Each route has same probability.

      Parameters:
      routes - list of routes
      Returns:
      picked route
    • randomLocomotive

      public Locomotive randomLocomotive​(ArrayList<Locomotive> locomotives)
      Pick random locomotive in a list.

      Each locomotive has same probability.

      Parameters:
      locomotives - list of locomotives
      Returns:
      picked locomotive
    • randomLocomotiveInAll

      public Locomotive randomLocomotiveInAll​(ArrayList<ArrayList<Locomotive>> locomotives)
      Pick random locomotive in multiple list.

      Each locomotive has same probability.

      Parameters:
      locomotives - list of list of locomotives
      Returns:
      picked locomotive
    • randomWeather

      public Weather randomWeather​(ArrayList<Weather> weathers)
      Pick random weather.

      Each weather has same probability.

      Parameters:
      weathers - list of weathers
      Returns:
      picked weather