|
@@ -36,11 +36,64 @@ public class CashMachineApp extends Application {
|
36
|
36
|
|
37
|
37
|
private Parent createContent() {
|
38
|
38
|
VBox vbox = new VBox(10);
|
39
|
|
- vbox.setPrefSize(600, 600);
|
40
|
|
- vbox.setStyle("-fx-background-color: mediumaquamarine; -fx-padding: 20; -fx-font-size: 20;");
|
|
39
|
+ vbox.setPrefSize(600, 750);
|
|
40
|
+ vbox.setStyle("-fx-background-color: lightslategray; -fx-padding: 20; -fx-font-size: 20;");
|
41
|
41
|
|
42
|
|
- TextArea areaInfo = new TextArea();
|
43
|
42
|
|
|
43
|
+ TextField areaAccountId = new TextField();
|
|
44
|
+ areaAccountId.setStyle("-fx-background-color: lightsteelblue;");
|
|
45
|
+ areaAccountId.setManaged(false);
|
|
46
|
+
|
|
47
|
+ Label accountId = new Label("Account ID:");
|
|
48
|
+ accountId.setManaged(false);
|
|
49
|
+
|
|
50
|
+ // HBox accountIdInfo = new HBox(5);
|
|
51
|
+ //accountIdInfo.getChildren().addAll(accountId, areaAccountId);
|
|
52
|
+
|
|
53
|
+ TextField areaAccountName = new TextField();
|
|
54
|
+ areaAccountName.setManaged(false);
|
|
55
|
+ areaAccountName.setStyle("-fx-background-color: lightsteelblue;");
|
|
56
|
+
|
|
57
|
+ Label accountName = new Label("Account Holder:");
|
|
58
|
+ accountName.setManaged(false);
|
|
59
|
+
|
|
60
|
+ //HBox nameInfo = new HBox(5);
|
|
61
|
+ //nameInfo.getChildren().addAll(accountName, areaAccountName);
|
|
62
|
+
|
|
63
|
+ TextField areaAccountEmail = new TextField();
|
|
64
|
+ areaAccountEmail.setManaged(false);
|
|
65
|
+ areaAccountEmail.setStyle("-fx-background-color: lightsteelblue;");
|
|
66
|
+
|
|
67
|
+ Label accountEmail = new Label("Email:");
|
|
68
|
+ accountEmail.setManaged(false);
|
|
69
|
+
|
|
70
|
+ //HBox accountEmailInfo = new HBox(5);
|
|
71
|
+ //accountEmailInfo.getChildren().addAll(accountEmail, areaAccountEmail);
|
|
72
|
+
|
|
73
|
+ TextField areaAccountAmount = new TextField();
|
|
74
|
+ areaAccountAmount.setManaged(false);
|
|
75
|
+ areaAccountAmount.setStyle("-fx-background-color: mediumturquoise;");
|
|
76
|
+
|
|
77
|
+ Label accountBalance = new Label("Balance:");
|
|
78
|
+ accountBalance.setManaged(false);
|
|
79
|
+
|
|
80
|
+ /*
|
|
81
|
+ HBox accountBalanceInfo = new HBox(5);
|
|
82
|
+ accountBalanceInfo.getChildren().addAll(accountBalance, areaAccountAmount);
|
|
83
|
+
|
|
84
|
+ accountIdInfo.setPrefSize(100, 100);
|
|
85
|
+ accountIdInfo.setStyle("-fx-background-color: mediumaquamarine; -fx-padding: 20; -fx-font-size: 20;");
|
|
86
|
+ */
|
|
87
|
+
|
|
88
|
+ field2.setManaged(false);
|
|
89
|
+
|
|
90
|
+ Label fieldLabel2 = new Label("Amount:");
|
|
91
|
+ fieldLabel2.setManaged(false);
|
|
92
|
+ Label fieldLabel = new Label("Select Your Account Number:");
|
|
93
|
+
|
|
94
|
+ field.setStyle("-fx-background-color: lightgrey;");
|
|
95
|
+ field2.setStyle("-fx-background-color: lightgrey;");
|
|
96
|
+ Label passwordLabel = new Label("Password:");
|
44
|
97
|
|
45
|
98
|
|
46
|
99
|
//Make Button Do something.
|
|
@@ -53,56 +106,109 @@ public class CashMachineApp extends Application {
|
53
|
106
|
*/
|
54
|
107
|
|
55
|
108
|
Button btnDeposit = new Button("Deposit");
|
56
|
|
- btnDeposit.setDisable(true);
|
|
109
|
+ btnDeposit.setManaged(false);
|
57
|
110
|
btnDeposit.setOnAction(e -> {
|
58
|
111
|
float amount = Float.parseFloat(field2.getText());
|
59
|
112
|
cashMachine.deposit(amount);
|
60
|
113
|
|
61
|
|
- areaInfo.setText(cashMachine.toString());
|
|
114
|
+ areaAccountAmount.setText(Float.toString(cashMachine.getBalance()));
|
62
|
115
|
});
|
63
|
116
|
|
64
|
117
|
|
65
|
118
|
Button btnWithdraw = new Button("Withdraw");
|
66
|
|
- btnWithdraw.setDisable(true);
|
|
119
|
+ btnWithdraw.setManaged(false);
|
67
|
120
|
btnWithdraw.setOnAction(e -> {
|
68
|
121
|
float amount = Float.parseFloat(field2.getText());
|
69
|
122
|
cashMachine.withdraw(amount);
|
70
|
|
- areaInfo.setText(cashMachine.toString());
|
|
123
|
+ areaAccountAmount.setText(Float.toString(cashMachine.getBalance()));
|
71
|
124
|
});
|
72
|
125
|
|
73
|
126
|
Button btnResetPassword = new Button("Reset Password");
|
74
|
|
- btnResetPassword.setDisable(true);
|
|
127
|
+ btnResetPassword.setManaged(false);
|
75
|
128
|
btnResetPassword.setOnAction(e -> {
|
76
|
129
|
int id = Integer.parseInt(accountNumbers.getValue().toString());
|
77
|
130
|
String password = field.getText();
|
78
|
131
|
cashMachine.resetPassword(id, password);
|
79
|
|
- areaInfo.setText(cashMachine.message("Password Reset."));
|
|
132
|
+ passwordLabel.setText(cashMachine.message("Password Reset."));
|
80
|
133
|
});
|
81
|
134
|
|
82
|
135
|
Button btnExit = new Button("Log Out");
|
|
136
|
+ btnExit.setManaged(false);
|
83
|
137
|
btnExit.setOnAction(e -> {
|
84
|
138
|
cashMachine.exit();
|
85
|
139
|
field.clear();
|
86
|
140
|
field2.clear();
|
87
|
|
- areaInfo.clear();
|
88
|
|
- btnDeposit.setDisable(true);
|
89
|
|
- btnWithdraw.setDisable(true);
|
90
|
|
- btnResetPassword.setDisable(true);
|
|
141
|
+ areaAccountAmount.clear();
|
|
142
|
+ areaAccountEmail.clear();
|
|
143
|
+ areaAccountId.clear();
|
|
144
|
+ areaAccountName.clear();
|
|
145
|
+ passwordLabel.setText("Password:");
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+ field2.setVisible(false);
|
|
149
|
+ fieldLabel2.setVisible(false);
|
|
150
|
+ btnDeposit.setVisible(false);
|
|
151
|
+ btnWithdraw.setVisible(false);
|
|
152
|
+ btnExit.setVisible(false);
|
|
153
|
+ btnResetPassword.setVisible(false);
|
|
154
|
+
|
|
155
|
+ areaAccountAmount.setVisible(false);
|
|
156
|
+ areaAccountEmail.setVisible(false);
|
|
157
|
+ areaAccountId.setVisible(false);
|
|
158
|
+ areaAccountName.setVisible(false);
|
|
159
|
+
|
|
160
|
+ accountBalance.setVisible(false);
|
|
161
|
+ accountEmail.setVisible(false);
|
|
162
|
+ accountId.setVisible(false);
|
|
163
|
+ accountName.setVisible(false);
|
91
|
164
|
});
|
92
|
165
|
|
93
|
166
|
Button btnSubmit = new Button("Enter");
|
94
|
167
|
btnSubmit.setOnAction(e -> {
|
95
|
168
|
int id = Integer.parseInt(accountNumbers.getValue().toString());
|
96
|
|
- String password = field.getText();
|
97
|
|
- if(cashMachine.checkPassword(id, password)) {
|
|
169
|
+ String passwordInput = field.getText();
|
|
170
|
+ if(cashMachine.checkPassword(id, passwordInput)) {
|
98
|
171
|
cashMachine.login(id);
|
99
|
|
- areaInfo.setText(cashMachine.toString());
|
100
|
|
- btnDeposit.setDisable(false);
|
101
|
|
- btnWithdraw.setDisable(false);
|
102
|
|
- btnResetPassword.setDisable(false);
|
103
|
|
- password = "New Password:";
|
|
172
|
+ areaAccountAmount.setText(Float.toString(cashMachine.getBalance()));
|
|
173
|
+ areaAccountEmail.setText(cashMachine.getEmail());
|
|
174
|
+ areaAccountId.setText(Integer.toString(cashMachine.getId()));
|
|
175
|
+ areaAccountName.setText(cashMachine.getName());
|
|
176
|
+ areaAccountAmount.setManaged(true);
|
|
177
|
+ areaAccountEmail.setManaged(true);
|
|
178
|
+ areaAccountId.setManaged(true);
|
|
179
|
+ areaAccountName.setManaged(true);
|
|
180
|
+ accountId.setManaged(true);
|
|
181
|
+ accountName.setManaged(true);
|
|
182
|
+ accountEmail.setManaged(true);
|
|
183
|
+ accountBalance.setManaged(true);
|
|
184
|
+ passwordLabel.setText("New Password:");
|
|
185
|
+ btnDeposit.setManaged(true);
|
|
186
|
+ btnWithdraw.setManaged(true);
|
|
187
|
+ btnExit.setManaged(true);
|
|
188
|
+ btnResetPassword.setManaged(true);
|
|
189
|
+ accountId.setManaged(true);
|
|
190
|
+ field2.setManaged(true);
|
|
191
|
+ fieldLabel2.setManaged(true);
|
|
192
|
+
|
|
193
|
+ field2.setVisible(true);
|
|
194
|
+ fieldLabel2.setVisible(true);
|
|
195
|
+ btnDeposit.setVisible(true);
|
|
196
|
+ btnWithdraw.setVisible(true);
|
|
197
|
+ btnExit.setVisible(true);
|
|
198
|
+ btnResetPassword.setVisible(true);
|
|
199
|
+
|
|
200
|
+ areaAccountAmount.setVisible(true);
|
|
201
|
+ areaAccountEmail.setVisible(true);
|
|
202
|
+ areaAccountId.setVisible(true);
|
|
203
|
+ areaAccountName.setVisible(true);
|
|
204
|
+
|
|
205
|
+ accountBalance.setVisible(true);
|
|
206
|
+ accountEmail.setVisible(true);
|
|
207
|
+ accountId.setVisible(true);
|
|
208
|
+ accountName.setVisible(true);
|
|
209
|
+
|
104
|
210
|
} else {
|
105
|
|
- areaInfo.setText(cashMachine.message("Incorrect Password. Try Again."));
|
|
211
|
+ areaAccountId.setText(cashMachine.message("Incorrect Password. Try Again."));
|
106
|
212
|
}
|
107
|
213
|
});
|
108
|
214
|
|
|
@@ -125,14 +231,8 @@ public class CashMachineApp extends Application {
|
125
|
231
|
flowpane2.getChildren().add(btnDeposit);
|
126
|
232
|
flowpane2.getChildren().add(btnWithdraw);
|
127
|
233
|
flowpane2.getChildren().add(btnExit);
|
128
|
|
- Label fieldLabel2 = new Label("Amount:");
|
129
|
|
- Label accountInfo2 = new Label("Account Info:");
|
130
|
234
|
|
131
|
|
- field.setStyle("-fx-background-color: lightgrey;");
|
132
|
|
- field2.setStyle("-fx-background-color: lightgrey;");
|
133
|
|
- Label fieldLabel = new Label("Account Number:");
|
134
|
|
- Label password = new Label("Password:");
|
135
|
|
- vbox.getChildren().addAll(fieldLabel, accountNumbers, password, field, flowpane, fieldLabel2, field2, flowpane2, accountInfo2, areaInfo);
|
|
235
|
+ vbox.getChildren().addAll(fieldLabel, accountNumbers, passwordLabel, field, flowpane, fieldLabel2, field2, flowpane2, accountId, areaAccountId, accountName, areaAccountName, accountEmail, areaAccountEmail, accountBalance, areaAccountAmount);
|
136
|
236
|
|
137
|
237
|
|
138
|
238
|
|