import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class DrawCounterSolution extends Application {
	private int stockCount_ = 24;
	private Label status_;
	private Button draw_;

	@Override
	public void start ( Stage stage ) {
		status_ = new Label(stockCount_ + " cards in stock");
		draw_ = new Button("Draw");
		draw_.setOnAction(event -> onDraw(event));

		VBox root = new VBox(10,status_,draw_);
		stage.setScene(new Scene(root,300,150));
		stage.setTitle("Draw Counter");
		stage.show();
	}

	private void onDraw ( ActionEvent event ) {
		System.out.println("Source: " + event.getSource());
		stockCount_--;
		status_.setText(stockCount_ + " cards in stock");
		draw_.setDisable(stockCount_ == 0);
	}

	public static void main ( String[] args ) {
		launch(args);
	}
}