java.lang.Object
com.github.freddyyj.randomtrainsimworld.Main
public class Main extends Object
main class for control logics
This class should be Singleton. Use
getInstance() to get this object.- Author:
- FreddyYJ_
-
Constructor Summary
Constructors Modifier Constructor Description protectedMain()default constructor -
Method Summary
Modifier and Type Method Description voidclose()Save and close save file.static MaingetInstance()Get instance.ArrayList<Locomotive>getLocomotive(String routeName)Get list ofLocomotiveobjects with specific route name.LocomotivegetLocomotive(String routeName, String locoName)GetLocomotiveobject with specific route name and locomotive name.HashMap<Route,ArrayList<Locomotive>>getLocos()Get locomotive list.RoutegetRoute(String name)GetRouteobject with specific name.ArrayList<Route>getRoutes()Get route list.StringgetSaveFilePath()Get savefile path.SaveLocogetUnselectedLocos()GetSaveLocothat has unselected routes and locos list.WeathergetWeather(String name)GetWeatherobject with specific weather name.ArrayList<Weather>getWeathers()Get weather list.booleanisSaveChanged()Get routes, locos or weathers selection are changed.static voidmain(String[] args)voidreload()Reload unselected routes, locos and weathers list.voidreloadSaveFile(String path)Reload savefile from specific path.voidsaveAs(String path)Save savefile at specific path.voidsaveConfig()Save configuration.voidselectLocomotive(boolean isSelected, Locomotive loco, Route route)Add or removeLocomotivefrom locomotive list.voidselectRoute(boolean isSelected, Route route)Add or removeRoutefrom routes list.voidselectWeather(boolean isSelected, Weather weather)Add or removeWeatherfrom weather list.voidsetSaveFilePath(String path)Set savefile path to specific path.
-
Constructor Details
-
Main
default constructor- Throws:
IOException
-
-
Method Details
-
getLocos
Get locomotive list.- Returns:
- locomotive list
-
main
-
getInstance
Get instance.- Returns:
- instance of this class
- Throws:
IOException
-
getUnselectedLocos
GetSaveLocothat has unselected routes and locos list.- Returns:
SaveLocoobject
-
reload
public void reload()Reload unselected routes, locos and weathers list. -
getRoutes
Get route list.- Returns:
- routes list
-
getWeathers
Get weather list.- Returns:
- weather list
-
getRoute
- Parameters:
name- route name- Returns:
Routeobject
-
getLocomotive
Get list ofLocomotiveobjects with specific route name.If routeName was not found, returns null.
- Parameters:
routeName- route name- Returns:
- list of
Locomotiveobject
-
getLocomotive
GetLocomotiveobject with specific route name and locomotive name.If routeName or locoName was not found, returns null.
- Parameters:
routeName- route namelocoName- locomotive name- Returns:
Locomotiveobject
-
getWeather
GetWeatherobject with specific weather name.If not found, return null.
- Parameters:
name- weather name- Returns:
Weatherobject
-
selectRoute
Add or removeRoutefrom routes list.- Parameters:
isSelected- add when true, remove when falseroute-Routethat want to add or remove
-
selectLocomotive
Add or removeLocomotivefrom locomotive list.- Parameters:
isSelected- add when true, remove when falseloco-Locomotivethat want to add or removeroute-Routeof loco
-
selectWeather
Add or removeWeatherfrom weather list.- Parameters:
isSelected- add when true, remove when falseweather-Weatherthat want to add or remove
-
close
Save and close save file.- Throws:
IOException
-
saveAs
Save savefile at specific path.- Parameters:
path- file path- Throws:
IOException
-
reloadSaveFile
Reload savefile from specific path.- Parameters:
path- file path- Throws:
FileNotFoundException
-
setSaveFilePath
Set savefile path to specific path.- Parameters:
path- file path
-
getSaveFilePath
Get savefile path.- Returns:
- file path
-
isSaveChanged
public boolean isSaveChanged()Get routes, locos or weathers selection are changed.- Returns:
- true if selection changed
-
saveConfig
Save configuration.- Throws:
IOException
-