ZipCloudBank's meh banking app.

CashMachineApp.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import javafx.application.Application;
  2. import javafx.scene.Parent;
  3. import javafx.scene.Scene;
  4. import javafx.scene.control.Button;
  5. import javafx.scene.control.TextArea;
  6. import javafx.scene.control.TextField;
  7. import javafx.scene.layout.VBox;
  8. import javafx.stage.Stage;
  9. import javafx.scene.layout.FlowPane;
  10. /**
  11. * @author ZipCodeWilmington
  12. */
  13. public class CashMachineApp extends Application {
  14. private TextField field = new TextField();
  15. private CashMachine cashMachine = new CashMachine(new Bank());
  16. private Parent createContent() {
  17. VBox vbox = new VBox(10);
  18. vbox.setPrefSize(600, 600);
  19. TextArea areaInfo = new TextArea();
  20. Button btnSubmit = new Button("Set Account ID");
  21. btnSubmit.setOnAction(e -> {
  22. int id = Integer.parseInt(field.getText());
  23. cashMachine.login(id);
  24. areaInfo.setText(cashMachine.toString());
  25. });
  26. Button btnDeposit = new Button("Deposit");
  27. btnDeposit.setOnAction(e -> {
  28. int amount = Integer.parseInt(field.getText());
  29. cashMachine.deposit(amount);
  30. areaInfo.setText(cashMachine.toString());
  31. });
  32. Button btnWithdraw = new Button("Withdraw");
  33. btnWithdraw.setOnAction(e -> {
  34. int amount = Integer.parseInt(field.getText());
  35. cashMachine.withdraw(amount);
  36. areaInfo.setText(cashMachine.toString());
  37. });
  38. Button btnExit = new Button("Exit");
  39. btnExit.setOnAction(e -> {
  40. cashMachine.exit();
  41. areaInfo.setText(cashMachine.toString());
  42. });
  43. FlowPane flowpane = new FlowPane();
  44. flowpane.getChildren().add(btnSubmit);
  45. flowpane.getChildren().add(btnDeposit);
  46. flowpane.getChildren().add(btnWithdraw);
  47. flowpane.getChildren().add(btnExit);
  48. vbox.getChildren().addAll(field, flowpane, areaInfo);
  49. return vbox;
  50. }
  51. @Override
  52. public void start(Stage stage) throws Exception {
  53. stage.setScene(new Scene(createContent()));
  54. stage.show();
  55. }
  56. public static void main(String[] args) {
  57. launch(args);
  58. }
  59. }