|
@@ -1,138 +1,138 @@
|
1
|
|
-package rocks.zipcode.atm;
|
2
|
|
-
|
3
|
|
-import javafx.geometry.Insets;
|
4
|
|
-import javafx.geometry.Pos;
|
5
|
|
-import javafx.scene.control.*;
|
6
|
|
-import javafx.scene.layout.GridPane;
|
7
|
|
-import javafx.scene.text.Text;
|
8
|
|
-import rocks.zipcode.atm.bank.Bank;
|
9
|
|
-import javafx.application.Application;
|
10
|
|
-import javafx.scene.Parent;
|
11
|
|
-import javafx.scene.Scene;
|
12
|
|
-import javafx.scene.layout.VBox;
|
13
|
|
-import javafx.stage.Stage;
|
14
|
|
-import javafx.scene.layout.FlowPane;
|
15
|
|
-
|
16
|
|
-import java.util.ArrayList;
|
17
|
|
-
|
18
|
|
-/**
|
19
|
|
- * @author ZipCodeWilmington
|
20
|
|
- */
|
21
|
|
-public class CashMachineApp extends Application {
|
22
|
|
-
|
23
|
|
- private TextField field = new TextField();
|
24
|
|
- private CashMachine cashMachine = new CashMachine(new Bank());
|
25
|
|
-
|
26
|
|
- private Parent createContent() {
|
27
|
|
- field.setFocusTraversable(false);
|
28
|
|
- field.setPromptText("Enter Account ID");
|
29
|
|
- FlowPane flowpane = new FlowPane();
|
30
|
|
- VBox vbox = new VBox(10);
|
31
|
|
- vbox.setPrefSize(600, 600);
|
32
|
|
-
|
33
|
|
- TextArea areaInfo = new TextArea();
|
34
|
|
-
|
35
|
|
- GridPane gridPane = new GridPane();
|
36
|
|
- gridPane.setAlignment(Pos.CENTER_LEFT);
|
37
|
|
- gridPane.setVgap(5);
|
38
|
|
- gridPane.setHgap(5);
|
39
|
|
- Text account = new Text();
|
40
|
|
- Text name = new Text();
|
41
|
|
- Text email = new Text();
|
42
|
|
- Text balance = new Text();
|
43
|
|
-
|
44
|
|
-
|
45
|
|
- MenuBar menuBar = new MenuBar();
|
46
|
|
-
|
47
|
|
- Button btnDeposit = new Button("Deposit");
|
48
|
|
- btnDeposit.setOnAction(e -> {
|
49
|
|
- int amount = Integer.parseInt(field.getText());
|
50
|
|
- cashMachine.deposit(amount);
|
51
|
|
-
|
52
|
|
- account.setText(cashMachine.accountIdToString());
|
53
|
|
- name.setText(cashMachine.nameToString());
|
54
|
|
- email.setText(cashMachine.emailToString());
|
55
|
|
- balance.setText(cashMachine.balanceToString());
|
56
|
|
- });
|
57
|
|
-
|
58
|
|
- Button btnWithdraw = new Button("Withdraw");
|
59
|
|
- btnWithdraw.setOnAction(e -> {
|
60
|
|
- int amount = Integer.parseInt(field.getText());
|
61
|
|
- cashMachine.withdraw(amount);
|
62
|
|
-
|
63
|
|
- account.setText(cashMachine.accountIdToString());
|
64
|
|
- name.setText(cashMachine.nameToString());
|
65
|
|
- email.setText(cashMachine.emailToString());
|
66
|
|
- balance.setText(cashMachine.balanceToString());
|
67
|
|
- });
|
68
|
|
-
|
69
|
|
- Button btnExit = new Button("Exit");
|
70
|
|
- btnExit.setOnAction(e -> {
|
71
|
|
- cashMachine.exit();
|
72
|
|
- account.setText(cashMachine.accountIdToString());
|
73
|
|
- name.setText(cashMachine.nameToString());
|
74
|
|
- email.setText(cashMachine.emailToString());
|
75
|
|
- balance.setText(cashMachine.balanceToString());
|
76
|
|
- });
|
77
|
|
-
|
78
|
|
- Button btnSubmit = new Button("Login");
|
79
|
|
- btnSubmit.setOnAction(e -> {
|
80
|
|
- int id = Integer.parseInt(field.getText());
|
81
|
|
- cashMachine.login(id);
|
82
|
|
- account.setText(cashMachine.accountIdToString());
|
83
|
|
- name.setText(cashMachine.nameToString());
|
84
|
|
- email.setText(cashMachine.emailToString());
|
85
|
|
- balance.setText(cashMachine.balanceToString());
|
86
|
|
- btnDeposit.setVisible(true);
|
87
|
|
- btnWithdraw.setVisible(true);
|
88
|
|
- btnExit.setVisible(true);
|
89
|
|
- menuBar.setVisible(true);
|
90
|
|
-
|
91
|
|
-
|
92
|
|
- });
|
93
|
|
-
|
94
|
|
- btnDeposit.setVisible(false);
|
95
|
|
- btnWithdraw.setVisible(false);
|
96
|
|
- btnExit.setVisible(false);
|
97
|
|
- menuBar.setVisible(false);
|
98
|
|
-
|
99
|
|
- Menu accountMenu = new Menu("All Accounts");
|
100
|
|
-
|
101
|
|
- flowpane.getChildren().add(btnSubmit);
|
102
|
|
- flowpane.getChildren().add(btnDeposit);
|
103
|
|
- flowpane.getChildren().add(btnWithdraw);
|
104
|
|
- flowpane.getChildren().add(btnExit);
|
105
|
|
- flowpane.getChildren().add(menuBar);
|
106
|
|
- menuBar.getMenus().add(accountMenu);
|
107
|
|
-
|
108
|
|
- ArrayList<String> accountList = cashMachine.listAccounts();
|
109
|
|
- for(String acct : accountList){
|
110
|
|
- MenuItem newItem = new MenuItem(acct);
|
111
|
|
- newItem.setOnAction(e -> {
|
112
|
|
- field.clear();
|
113
|
|
- field.setPromptText("Enter Id and click \"Login\"");
|
114
|
|
- });
|
115
|
|
-
|
116
|
|
- accountMenu.getItems().add(newItem);
|
117
|
|
-
|
118
|
|
- }
|
119
|
|
-
|
120
|
|
- gridPane.setPadding(new Insets(25,25,25,25));
|
121
|
|
- gridPane.add(account,0,1);
|
122
|
|
- gridPane.add(name,0,2);
|
123
|
|
- gridPane.add(email,0,3);
|
124
|
|
- gridPane.add(balance,0,4);
|
125
|
|
- vbox.getChildren().addAll(field, flowpane, gridPane);
|
126
|
|
- return vbox;
|
127
|
|
- }
|
128
|
|
-
|
129
|
|
- @Override
|
130
|
|
- public void start(Stage stage) throws Exception {
|
131
|
|
- stage.setScene(new Scene(createContent()));
|
132
|
|
- stage.show();
|
133
|
|
- }
|
134
|
|
-
|
135
|
|
- public static void main(String[] args) {
|
136
|
|
- launch(args);
|
137
|
|
- }
|
138
|
|
-}
|
|
1
|
+//package rocks.zipcode.atm;
|
|
2
|
+//
|
|
3
|
+//import javafx.geometry.Insets;
|
|
4
|
+//import javafx.geometry.Pos;
|
|
5
|
+//import javafx.scene.control.*;
|
|
6
|
+//import javafx.scene.layout.GridPane;
|
|
7
|
+//import javafx.scene.text.Text;
|
|
8
|
+//import rocks.zipcode.atm.bank.Bank;
|
|
9
|
+//import javafx.application.Application;
|
|
10
|
+//import javafx.scene.Parent;
|
|
11
|
+//import javafx.scene.Scene;
|
|
12
|
+//import javafx.scene.layout.VBox;
|
|
13
|
+//import javafx.stage.Stage;
|
|
14
|
+//import javafx.scene.layout.FlowPane;
|
|
15
|
+//
|
|
16
|
+//import java.util.ArrayList;
|
|
17
|
+//
|
|
18
|
+///**
|
|
19
|
+// * @author ZipCodeWilmington
|
|
20
|
+// */
|
|
21
|
+//public class CashMachineApp extends Application {
|
|
22
|
+//
|
|
23
|
+// private TextField field = new TextField();
|
|
24
|
+// private CashMachine cashMachine = new CashMachine(new Bank());
|
|
25
|
+//
|
|
26
|
+// private Parent createContent() {
|
|
27
|
+// field.setFocusTraversable(false);
|
|
28
|
+// field.setPromptText("Enter Account ID");
|
|
29
|
+// FlowPane flowpane = new FlowPane();
|
|
30
|
+// VBox vbox = new VBox(10);
|
|
31
|
+// vbox.setPrefSize(600, 600);
|
|
32
|
+//
|
|
33
|
+// TextArea areaInfo = new TextArea();
|
|
34
|
+//
|
|
35
|
+// GridPane gridPane = new GridPane();
|
|
36
|
+// gridPane.setAlignment(Pos.CENTER_LEFT);
|
|
37
|
+// gridPane.setVgap(5);
|
|
38
|
+// gridPane.setHgap(5);
|
|
39
|
+// Text account = new Text();
|
|
40
|
+// Text name = new Text();
|
|
41
|
+// Text email = new Text();
|
|
42
|
+// Text balance = new Text();
|
|
43
|
+//
|
|
44
|
+//
|
|
45
|
+// MenuBar menuBar = new MenuBar();
|
|
46
|
+//
|
|
47
|
+// Button btnDeposit = new Button("Deposit");
|
|
48
|
+// btnDeposit.setOnAction(e -> {
|
|
49
|
+// int amount = Integer.parseInt(field.getText());
|
|
50
|
+// cashMachine.deposit(amount);
|
|
51
|
+//
|
|
52
|
+// account.setText(cashMachine.accountIdToString());
|
|
53
|
+// name.setText(cashMachine.nameToString());
|
|
54
|
+// email.setText(cashMachine.emailToString());
|
|
55
|
+// balance.setText(cashMachine.balanceToString());
|
|
56
|
+// });
|
|
57
|
+//
|
|
58
|
+// Button btnWithdraw = new Button("Withdraw");
|
|
59
|
+// btnWithdraw.setOnAction(e -> {
|
|
60
|
+// int amount = Integer.parseInt(field.getText());
|
|
61
|
+// cashMachine.withdraw(amount);
|
|
62
|
+//
|
|
63
|
+// account.setText(cashMachine.accountIdToString());
|
|
64
|
+// name.setText(cashMachine.nameToString());
|
|
65
|
+// email.setText(cashMachine.emailToString());
|
|
66
|
+// balance.setText(cashMachine.balanceToString());
|
|
67
|
+// });
|
|
68
|
+//
|
|
69
|
+// Button btnExit = new Button("Exit");
|
|
70
|
+// btnExit.setOnAction(e -> {
|
|
71
|
+// cashMachine.exit();
|
|
72
|
+// account.setText(cashMachine.accountIdToString());
|
|
73
|
+// name.setText(cashMachine.nameToString());
|
|
74
|
+// email.setText(cashMachine.emailToString());
|
|
75
|
+// balance.setText(cashMachine.balanceToString());
|
|
76
|
+// });
|
|
77
|
+//
|
|
78
|
+// Button btnSubmit = new Button("Login");
|
|
79
|
+// btnSubmit.setOnAction(e -> {
|
|
80
|
+// int id = Integer.parseInt(field.getText());
|
|
81
|
+// cashMachine.login(id);
|
|
82
|
+// account.setText(cashMachine.accountIdToString());
|
|
83
|
+// name.setText(cashMachine.nameToString());
|
|
84
|
+// email.setText(cashMachine.emailToString());
|
|
85
|
+// balance.setText(cashMachine.balanceToString());
|
|
86
|
+// btnDeposit.setVisible(true);
|
|
87
|
+// btnWithdraw.setVisible(true);
|
|
88
|
+// btnExit.setVisible(true);
|
|
89
|
+// menuBar.setVisible(true);
|
|
90
|
+//
|
|
91
|
+//
|
|
92
|
+// });
|
|
93
|
+//
|
|
94
|
+// btnDeposit.setVisible(false);
|
|
95
|
+// btnWithdraw.setVisible(false);
|
|
96
|
+// btnExit.setVisible(false);
|
|
97
|
+// menuBar.setVisible(false);
|
|
98
|
+//
|
|
99
|
+// Menu accountMenu = new Menu("All Accounts");
|
|
100
|
+//
|
|
101
|
+// flowpane.getChildren().add(btnSubmit);
|
|
102
|
+// flowpane.getChildren().add(btnDeposit);
|
|
103
|
+// flowpane.getChildren().add(btnWithdraw);
|
|
104
|
+// flowpane.getChildren().add(btnExit);
|
|
105
|
+// flowpane.getChildren().add(menuBar);
|
|
106
|
+// menuBar.getMenus().add(accountMenu);
|
|
107
|
+//
|
|
108
|
+// ArrayList<String> accountList = cashMachine.listAccounts();
|
|
109
|
+// for(String acct : accountList){
|
|
110
|
+// MenuItem newItem = new MenuItem(acct);
|
|
111
|
+// newItem.setOnAction(e -> {
|
|
112
|
+// field.clear();
|
|
113
|
+// field.setPromptText("Enter Id and click \"Login\"");
|
|
114
|
+// });
|
|
115
|
+//
|
|
116
|
+// accountMenu.getItems().add(newItem);
|
|
117
|
+//
|
|
118
|
+// }
|
|
119
|
+//
|
|
120
|
+// gridPane.setPadding(new Insets(25,25,25,25));
|
|
121
|
+// gridPane.add(account,0,1);
|
|
122
|
+// gridPane.add(name,0,2);
|
|
123
|
+// gridPane.add(email,0,3);
|
|
124
|
+// gridPane.add(balance,0,4);
|
|
125
|
+// vbox.getChildren().addAll(field, flowpane, gridPane);
|
|
126
|
+// return vbox;
|
|
127
|
+// }
|
|
128
|
+//
|
|
129
|
+// @Override
|
|
130
|
+// public void start(Stage stage) throws Exception {
|
|
131
|
+// stage.setScene(new Scene(createContent()));
|
|
132
|
+// stage.show();
|
|
133
|
+// }
|
|
134
|
+//
|
|
135
|
+// public static void main(String[] args) {
|
|
136
|
+// launch(args);
|
|
137
|
+// }
|
|
138
|
+//}
|