Last active
September 26, 2018 14:05
-
-
Save greyscaled/661c48706bdb7f13fc74ca092faf05bc to your computer and use it in GitHub Desktop.
SlotMachine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.beans.property.SimpleStringProperty; | |
/** | |
* Class representing a transit ticket vending machine. This is an example | |
* and only demonstrates a single property: selecting a transit route. | |
*/ | |
public final class SlotMachine { | |
/** | |
* ROUTES that tickets can be issued for | |
*/ | |
public static enum ROUTES { | |
/** | |
* Route 1 - DavidParnasAlley | |
*/ | |
ROUTE1, | |
/** | |
* Route 2 - KnuthVille | |
*/ | |
ROUTE2 | |
} | |
/** | |
* currently selected route for which tickets are to be issued | |
*/ | |
private final SimpleStringProperty selectedRoute = new SimpleStringProperty(); | |
/** | |
* Constructor. | |
*/ | |
public SlotMachine() { | |
setSelectedRoute(""); | |
} | |
/** | |
* Returns selected route property itself | |
* | |
* @return selectedRoute property | |
*/ | |
public SimpleStringProperty selectedRouteProperty() { | |
return selectedRoute; | |
} | |
/** | |
* Returns currently selected route | |
* | |
* @return selected route | |
*/ | |
public String getSelectedRoute() { | |
return selectedRoute.get(); | |
} | |
/** | |
* Selected route to purchase tickets for | |
* | |
* @param route The route | |
*/ | |
public void setSelectedRoute(ROUTES route) { | |
setSelectedRoute(route.toString()); | |
} | |
/** | |
* Selected route to purchase tickets for | |
* | |
* @param route the route | |
*/ | |
private void setSelectedRoute(String route) { | |
selectedRoute.set(route); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment