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 protected
Main()
default constructor -
Method Summary
Modifier and Type Method Description void
close()
Save and close save file.static Main
getInstance()
Get instance.ArrayList<Locomotive>
getLocomotive(String routeName)
Get list ofLocomotive
objects with specific route name.Locomotive
getLocomotive(String routeName, String locoName)
GetLocomotive
object with specific route name and locomotive name.HashMap<Route,ArrayList<Locomotive>>
getLocos()
Get locomotive list.Route
getRoute(String name)
GetRoute
object with specific name.ArrayList<Route>
getRoutes()
Get route list.String
getSaveFilePath()
Get savefile path.SaveLoco
getUnselectedLocos()
GetSaveLoco
that has unselected routes and locos list.Weather
getWeather(String name)
GetWeather
object with specific weather name.ArrayList<Weather>
getWeathers()
Get weather list.boolean
isSaveChanged()
Get routes, locos or weathers selection are changed.static void
main(String[] args)
void
reload()
Reload unselected routes, locos and weathers list.void
reloadSaveFile(String path)
Reload savefile from specific path.void
saveAs(String path)
Save savefile at specific path.void
saveConfig()
Save configuration.void
selectLocomotive(boolean isSelected, Locomotive loco, Route route)
Add or removeLocomotive
from locomotive list.void
selectRoute(boolean isSelected, Route route)
Add or removeRoute
from routes list.void
selectWeather(boolean isSelected, Weather weather)
Add or removeWeather
from weather list.void
setSaveFilePath(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
GetSaveLoco
that has unselected routes and locos list.- Returns:
SaveLoco
object
-
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:
Route
object
-
getLocomotive
Get list ofLocomotive
objects with specific route name.If routeName was not found, returns null.
- Parameters:
routeName
- route name- Returns:
- list of
Locomotive
object
-
getLocomotive
GetLocomotive
object with specific route name and locomotive name.If routeName or locoName was not found, returns null.
- Parameters:
routeName
- route namelocoName
- locomotive name- Returns:
Locomotive
object
-
getWeather
GetWeather
object with specific weather name.If not found, return null.
- Parameters:
name
- weather name- Returns:
Weather
object
-
selectRoute
Add or removeRoute
from routes list.- Parameters:
isSelected
- add when true, remove when falseroute
-Route
that want to add or remove
-
selectLocomotive
Add or removeLocomotive
from locomotive list.- Parameters:
isSelected
- add when true, remove when falseloco
-Locomotive
that want to add or removeroute
-Route
of loco
-
selectWeather
Add or removeWeather
from weather list.- Parameters:
isSelected
- add when true, remove when falseweather
-Weather
that 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
-