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 Summary
Constructors Modifier Constructor Description protected
Random()
Constructor -
Method Summary
Modifier and Type Method Description static Random
getInstance()
Get instance of this class.Locomotive
randomLocomotive(ArrayList<Locomotive> locomotives)
Pick random locomotive in a list.Locomotive
randomLocomotiveInAll(ArrayList<ArrayList<Locomotive>> locomotives)
Pick random locomotive in multiple list.Route
randomRoute(ArrayList<Route> routes)
Pick random route.Weather
randomWeather(ArrayList<Weather> weathers)
Pick random weather.
-
Constructor Details
-
Random
protected Random()Constructor
-
-
Method Details
-
getInstance
Get instance of this class.- Returns:
- Random
-
randomRoute
Pick random route.Each route has same probability.
- Parameters:
routes
- list of routes- Returns:
- picked route
-
randomLocomotive
Pick random locomotive in a list.Each locomotive has same probability.
- Parameters:
locomotives
- list of locomotives- Returns:
- picked locomotive
-
randomLocomotiveInAll
Pick random locomotive in multiple list.Each locomotive has same probability.
- Parameters:
locomotives
- list of list of locomotives- Returns:
- picked locomotive
-
randomWeather
Pick random weather.Each weather has same probability.
- Parameters:
weathers
- list of weathers- Returns:
- picked weather
-