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 protectedRandom()Constructor -
Method Summary
Modifier and Type Method Description static RandomgetInstance()Get instance of this class.LocomotiverandomLocomotive(ArrayList<Locomotive> locomotives)Pick random locomotive in a list.LocomotiverandomLocomotiveInAll(ArrayList<ArrayList<Locomotive>> locomotives)Pick random locomotive in multiple list.RouterandomRoute(ArrayList<Route> routes)Pick random route.WeatherrandomWeather(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
-