|
@@ -1,78 +1,278 @@
|
1
|
1
|
package rocks.zipcode.atm;
|
2
|
2
|
|
|
3
|
+import javafx.geometry.Pos;
|
|
4
|
+import javafx.scene.control.*;
|
|
5
|
+import javafx.scene.control.Button;
|
|
6
|
+import javafx.scene.control.Label;
|
|
7
|
+import javafx.scene.control.TextArea;
|
|
8
|
+import javafx.scene.control.TextField;
|
|
9
|
+import javafx.scene.image.ImageViewBuilder;
|
|
10
|
+import javafx.scene.layout.HBox;
|
|
11
|
+import javafx.scene.text.TextAlignment;
|
|
12
|
+import javafx.scene.text.TextFlow;
|
|
13
|
+import javafx.stage.StageStyle;
|
3
|
14
|
import rocks.zipcode.atm.bank.Bank;
|
4
|
15
|
import javafx.application.Application;
|
5
|
16
|
import javafx.scene.Parent;
|
6
|
17
|
import javafx.scene.Scene;
|
7
|
|
-import javafx.scene.control.Button;
|
8
|
|
-import javafx.scene.control.TextArea;
|
9
|
|
-import javafx.scene.control.TextField;
|
10
|
18
|
import javafx.scene.layout.VBox;
|
11
|
19
|
import javafx.stage.Stage;
|
12
|
20
|
import javafx.scene.layout.FlowPane;
|
13
|
21
|
|
|
22
|
+
|
|
23
|
+import javax.swing.*;
|
|
24
|
+import javax.swing.text.html.ImageView;
|
|
25
|
+import javax.xml.soap.Text;
|
|
26
|
+import java.awt.*;
|
|
27
|
+import java.awt.Image;
|
|
28
|
+import java.io.FileInputStream;
|
|
29
|
+import java.util.HashMap;
|
|
30
|
+
|
14
|
31
|
/**
|
15
|
32
|
* @author ZipCodeWilmington
|
16
|
33
|
*/
|
17
|
34
|
public class CashMachineApp extends Application {
|
18
|
35
|
|
19
|
36
|
private TextField field = new TextField();
|
|
37
|
+ private TextField field2 = new TextField();
|
20
|
38
|
private CashMachine cashMachine = new CashMachine(new Bank());
|
|
39
|
+ private ComboBox accountNumbers = new ComboBox(cashMachine.getIdList());
|
21
|
40
|
|
22
|
41
|
private Parent createContent() {
|
23
|
42
|
VBox vbox = new VBox(10);
|
24
|
|
- vbox.setPrefSize(600, 600);
|
|
43
|
+ vbox.setPrefSize(600, 820);
|
|
44
|
+ vbox.setStyle("-fx-background-color: lightslategray; -fx-padding: 20; -fx-font-size: 20;");
|
|
45
|
+
|
|
46
|
+ Label header = new Label("Welcome to ZipCloud Bank");
|
|
47
|
+ header.setStyle("-fx-text-fill: turquoise; -fx-font-size: 42; -fx-font-family: Charter; -fx-border-radius: 10; -fx-label-padding: 8; -fx-border-width: 4; -fx-border-color: greenyellow;");
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+ TextField areaAccountId = new TextField();
|
|
52
|
+ areaAccountId.setStyle("-fx-background-color: lightsteelblue;");
|
|
53
|
+ areaAccountId.setManaged(false);
|
|
54
|
+ areaAccountId.setEditable(false);
|
|
55
|
+
|
|
56
|
+ Label accountId = new Label("Account ID:");
|
|
57
|
+ accountId.setManaged(false);
|
|
58
|
+ accountId.setStyle("-fx-text-fill: white;");
|
|
59
|
+
|
|
60
|
+ // HBox accountIdInfo = new HBox(5);
|
|
61
|
+ //accountIdInfo.getChildren().addAll(accountId, areaAccountId);
|
25
|
62
|
|
26
|
|
- TextArea areaInfo = new TextArea();
|
|
63
|
+ TextField areaAccountName = new TextField();
|
|
64
|
+ areaAccountName.setManaged(false);
|
|
65
|
+ areaAccountName.setStyle("-fx-background-color: lightsteelblue;");
|
|
66
|
+ areaAccountName.setEditable(false);
|
27
|
67
|
|
28
|
|
- Button btnSubmit = new Button("Set Account ID");
|
|
68
|
+ Label accountName = new Label("Account Holder:");
|
|
69
|
+ accountName.setStyle("-fx-text-fill: white;");
|
|
70
|
+ accountName.setManaged(false);
|
|
71
|
+
|
|
72
|
+ //HBox nameInfo = new HBox(5);
|
|
73
|
+ //nameInfo.getChildren().addAll(accountName, areaAccountName);
|
|
74
|
+
|
|
75
|
+ TextField areaAccountEmail = new TextField();
|
|
76
|
+ areaAccountEmail.setManaged(false);
|
|
77
|
+ areaAccountEmail.setStyle("-fx-background-color: lightsteelblue;");
|
|
78
|
+ areaAccountEmail.setEditable(false);
|
|
79
|
+
|
|
80
|
+ Label accountEmail = new Label("Email:");
|
|
81
|
+ accountEmail.setStyle("-fx-text-fill: white;");
|
|
82
|
+ accountEmail.setManaged(false);
|
|
83
|
+
|
|
84
|
+ //HBox accountEmailInfo = new HBox(5);
|
|
85
|
+ //accountEmailInfo.getChildren().addAll(accountEmail, areaAccountEmail);
|
|
86
|
+
|
|
87
|
+ TextField areaAccountAmount = new TextField();
|
|
88
|
+ areaAccountAmount.setManaged(false);
|
|
89
|
+ areaAccountAmount.setStyle("-fx-background-color: mediumturquoise;");
|
|
90
|
+ areaAccountAmount.setEditable(false);
|
|
91
|
+
|
|
92
|
+ Label accountBalance = new Label("Balance:");
|
|
93
|
+ accountBalance.setStyle("-fx-text-fill: greenyellow;");
|
|
94
|
+ accountBalance.setManaged(false);
|
|
95
|
+
|
|
96
|
+ /*
|
|
97
|
+ HBox accountBalanceInfo = new HBox(5);
|
|
98
|
+ accountBalanceInfo.getChildren().addAll(accountBalance, areaAccountAmount);
|
|
99
|
+
|
|
100
|
+ accountIdInfo.setPrefSize(100, 100);
|
|
101
|
+ accountIdInfo.setStyle("-fx-background-color: mediumaquamarine; -fx-padding: 20; -fx-font-size: 20;");
|
|
102
|
+ */
|
|
103
|
+
|
|
104
|
+ field2.setManaged(false);
|
|
105
|
+
|
|
106
|
+ Label fieldLabel2 = new Label("Amount:");
|
|
107
|
+ fieldLabel2.setManaged(false);
|
|
108
|
+ fieldLabel2.setStyle("-fx-text-fill: greenyellow;");
|
|
109
|
+ Label fieldLabel = new Label("Select Your Account Number:");
|
|
110
|
+ fieldLabel.setStyle("-fx-text-fill: greenyellow;");
|
|
111
|
+
|
|
112
|
+ field.setStyle("-fx-background-color: lightgrey;");
|
|
113
|
+ field2.setStyle("-fx-background-color: lightgrey;");
|
|
114
|
+ Label passwordLabel = new Label("Password:");
|
|
115
|
+ passwordLabel.setStyle("-fx-text-fill: greenyellow;");
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+ //Make Button Do something.
|
|
119
|
+ Button btnNewAccount = new Button("Setup New Account");
|
|
120
|
+ btnNewAccount.setDisable(true);
|
|
121
|
+ /*
|
29
|
122
|
btnSubmit.setOnAction(e -> {
|
30
|
|
- int id = Integer.parseInt(field.getText());
|
31
|
|
- cashMachine.login(id);
|
32
|
123
|
|
33
|
|
- areaInfo.setText(cashMachine.toString());
|
34
|
124
|
});
|
|
125
|
+*/
|
35
|
126
|
|
36
|
127
|
Button btnDeposit = new Button("Deposit");
|
|
128
|
+ btnDeposit.setManaged(false);
|
37
|
129
|
btnDeposit.setOnAction(e -> {
|
38
|
|
- int amount = Integer.parseInt(field.getText());
|
|
130
|
+ float amount = Float.parseFloat(field2.getText());
|
39
|
131
|
cashMachine.deposit(amount);
|
40
|
132
|
|
41
|
|
- areaInfo.setText(cashMachine.toString());
|
|
133
|
+ areaAccountAmount.setText(Float.toString(cashMachine.getBalance()));
|
42
|
134
|
});
|
43
|
135
|
|
|
136
|
+
|
44
|
137
|
Button btnWithdraw = new Button("Withdraw");
|
|
138
|
+ btnWithdraw.setManaged(false);
|
45
|
139
|
btnWithdraw.setOnAction(e -> {
|
46
|
|
- int amount = Integer.parseInt(field.getText());
|
|
140
|
+ float amount = Float.parseFloat(field2.getText());
|
47
|
141
|
cashMachine.withdraw(amount);
|
|
142
|
+ areaAccountAmount.setText(Float.toString(cashMachine.getBalance()));
|
|
143
|
+ });
|
48
|
144
|
|
49
|
|
- areaInfo.setText(cashMachine.toString());
|
|
145
|
+ Button btnResetPassword = new Button("Reset Password");
|
|
146
|
+ btnResetPassword.setManaged(false);
|
|
147
|
+ btnResetPassword.setOnAction(e -> {
|
|
148
|
+ int id = Integer.parseInt(accountNumbers.getValue().toString());
|
|
149
|
+ String password = field.getText();
|
|
150
|
+ cashMachine.resetPassword(id, password);
|
|
151
|
+ passwordLabel.setText(cashMachine.message("Password Reset."));
|
50
|
152
|
});
|
51
|
153
|
|
52
|
|
- Button btnExit = new Button("Exit");
|
|
154
|
+ Button btnExit = new Button("Log Out");
|
|
155
|
+ btnExit.setManaged(false);
|
53
|
156
|
btnExit.setOnAction(e -> {
|
54
|
157
|
cashMachine.exit();
|
|
158
|
+ field.clear();
|
|
159
|
+ field2.clear();
|
|
160
|
+ areaAccountAmount.clear();
|
|
161
|
+ areaAccountEmail.clear();
|
|
162
|
+ areaAccountId.clear();
|
|
163
|
+ areaAccountName.clear();
|
|
164
|
+ passwordLabel.setText("Password:");
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+ field2.setVisible(false);
|
|
168
|
+ fieldLabel2.setVisible(false);
|
|
169
|
+ btnDeposit.setVisible(false);
|
|
170
|
+ btnWithdraw.setVisible(false);
|
|
171
|
+ btnExit.setVisible(false);
|
|
172
|
+ btnResetPassword.setVisible(false);
|
|
173
|
+
|
|
174
|
+ areaAccountAmount.setVisible(false);
|
|
175
|
+ areaAccountEmail.setVisible(false);
|
|
176
|
+ areaAccountId.setVisible(false);
|
|
177
|
+ areaAccountName.setVisible(false);
|
|
178
|
+
|
|
179
|
+ accountBalance.setVisible(false);
|
|
180
|
+ accountEmail.setVisible(false);
|
|
181
|
+ accountId.setVisible(false);
|
|
182
|
+ accountName.setVisible(false);
|
|
183
|
+ });
|
|
184
|
+
|
|
185
|
+ Button btnSubmit = new Button("Enter");
|
|
186
|
+ btnSubmit.setOnAction(e -> {
|
|
187
|
+ int id = Integer.parseInt(accountNumbers.getValue().toString());
|
|
188
|
+ String passwordInput = field.getText();
|
|
189
|
+ if(cashMachine.checkPassword(id, passwordInput)) {
|
|
190
|
+ cashMachine.login(id);
|
|
191
|
+ areaAccountAmount.setText(Float.toString(cashMachine.getBalance()));
|
|
192
|
+ areaAccountEmail.setText(cashMachine.getEmail());
|
|
193
|
+ areaAccountId.setText(Integer.toString(cashMachine.getId()));
|
|
194
|
+ areaAccountName.setText(cashMachine.getName());
|
|
195
|
+ areaAccountAmount.setManaged(true);
|
|
196
|
+ areaAccountEmail.setManaged(true);
|
|
197
|
+ areaAccountId.setManaged(true);
|
|
198
|
+ areaAccountName.setManaged(true);
|
|
199
|
+ accountId.setManaged(true);
|
|
200
|
+ accountName.setManaged(true);
|
|
201
|
+ accountEmail.setManaged(true);
|
|
202
|
+ accountBalance.setManaged(true);
|
|
203
|
+ passwordLabel.setText("New Password:");
|
|
204
|
+ btnDeposit.setManaged(true);
|
|
205
|
+ btnWithdraw.setManaged(true);
|
|
206
|
+ btnExit.setManaged(true);
|
|
207
|
+ btnResetPassword.setManaged(true);
|
|
208
|
+ accountId.setManaged(true);
|
|
209
|
+ field2.setManaged(true);
|
|
210
|
+ fieldLabel2.setManaged(true);
|
|
211
|
+
|
|
212
|
+ field2.setVisible(true);
|
|
213
|
+ fieldLabel2.setVisible(true);
|
|
214
|
+ btnDeposit.setVisible(true);
|
|
215
|
+ btnWithdraw.setVisible(true);
|
|
216
|
+ btnExit.setVisible(true);
|
|
217
|
+ btnResetPassword.setVisible(true);
|
|
218
|
+
|
|
219
|
+ areaAccountAmount.setVisible(true);
|
|
220
|
+ areaAccountEmail.setVisible(true);
|
|
221
|
+ areaAccountId.setVisible(true);
|
|
222
|
+ areaAccountName.setVisible(true);
|
|
223
|
+
|
|
224
|
+ accountBalance.setVisible(true);
|
|
225
|
+ accountEmail.setVisible(true);
|
|
226
|
+ accountId.setVisible(true);
|
|
227
|
+ accountName.setVisible(true);
|
55
|
228
|
|
56
|
|
- areaInfo.setText(cashMachine.toString());
|
|
229
|
+ } else {
|
|
230
|
+ passwordLabel.setText(cashMachine.message("Incorrect Password. Try Again."));
|
|
231
|
+ }
|
57
|
232
|
});
|
58
|
233
|
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+ /*
|
|
237
|
+ String path = "https://drive.google.com/file/d/1PR_cLhzJ9IFcnWF46QSX_WEcnFT-uI0Q/view?usp=sharing";
|
|
238
|
+
|
|
239
|
+ Image image = new Image(path);
|
|
240
|
+*/
|
|
241
|
+
|
59
|
242
|
FlowPane flowpane = new FlowPane();
|
60
|
243
|
|
61
|
244
|
flowpane.getChildren().add(btnSubmit);
|
62
|
|
- flowpane.getChildren().add(btnDeposit);
|
63
|
|
- flowpane.getChildren().add(btnWithdraw);
|
64
|
|
- flowpane.getChildren().add(btnExit);
|
65
|
|
- vbox.getChildren().addAll(field, flowpane, areaInfo);
|
|
245
|
+ flowpane.getChildren().add(btnResetPassword);
|
|
246
|
+ flowpane.getChildren().add(btnNewAccount);
|
|
247
|
+
|
|
248
|
+ FlowPane flowpane2 = new FlowPane();
|
|
249
|
+
|
|
250
|
+ flowpane2.getChildren().add(btnDeposit);
|
|
251
|
+ flowpane2.getChildren().add(btnWithdraw);
|
|
252
|
+ flowpane2.getChildren().add(btnExit);
|
|
253
|
+
|
|
254
|
+ vbox.getChildren().addAll(header, fieldLabel, accountNumbers, passwordLabel, field, flowpane, fieldLabel2, field2, flowpane2, accountId, areaAccountId, accountName, areaAccountName, accountEmail, areaAccountEmail, accountBalance, areaAccountAmount);
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
66
|
258
|
return vbox;
|
|
259
|
+
|
|
260
|
+
|
67
|
261
|
}
|
68
|
262
|
|
69
|
263
|
@Override
|
70
|
|
- public void start(Stage stage) throws Exception {
|
71
|
|
- stage.setScene(new Scene(createContent()));
|
72
|
|
- stage.show();
|
|
264
|
+ public void start(Stage primarystage) throws Exception {
|
|
265
|
+ primarystage.setTitle("ZipCloud Bank");
|
|
266
|
+ primarystage.setScene(new Scene(createContent()));
|
|
267
|
+ primarystage.show();
|
|
268
|
+
|
73
|
269
|
}
|
74
|
270
|
|
75
|
271
|
public static void main(String[] args) {
|
|
272
|
+
|
76
|
273
|
launch(args);
|
|
274
|
+
|
77
|
275
|
}
|
|
276
|
+
|
|
277
|
+
|
78
|
278
|
}
|