|
@@ -1,5 +1,6 @@
|
1
|
1
|
package rocks.zipcode.atm;
|
2
|
2
|
|
|
3
|
+import javafx.scene.text.Text;
|
3
|
4
|
import rocks.zipcode.atm.bank.Bank;
|
4
|
5
|
import javafx.application.Application;
|
5
|
6
|
import javafx.scene.Parent;
|
|
@@ -18,32 +19,78 @@ public class CashMachineApp extends Application {
|
18
|
19
|
|
19
|
20
|
private TextField field = new TextField();
|
20
|
21
|
private CashMachine cashMachine = new CashMachine(new Bank());
|
|
22
|
+ private TextField amountField = new TextField();
|
21
|
23
|
|
22
|
24
|
private Parent createContent() {
|
|
25
|
+ field.setPromptText("Enter your account ID");
|
|
26
|
+ field.setFocusTraversable(false);
|
|
27
|
+
|
23
|
28
|
VBox vbox = new VBox(10);
|
24
|
29
|
vbox.setPrefSize(600, 600);
|
25
|
30
|
|
26
|
|
- TextArea areaInfo = new TextArea();
|
|
31
|
+ Text areaInfo = new Text();
|
|
32
|
+ areaInfo.setVisible(false);
|
|
33
|
+
|
|
34
|
+ FlowPane flowpane = new FlowPane();
|
27
|
35
|
|
28
|
|
- Button btnSubmit = new Button("Set Account ID");
|
|
36
|
+ Button btnSubmit = new Button("Login");
|
29
|
37
|
btnSubmit.setOnAction(e -> {
|
30
|
38
|
int id = Integer.parseInt(field.getText());
|
31
|
39
|
cashMachine.login(id);
|
32
|
|
-
|
33
|
|
- areaInfo.setText(cashMachine.toString());
|
34
|
40
|
});
|
|
41
|
+//
|
|
42
|
+// String[] acctFields;
|
|
43
|
+// acctFields = String.valueOf(areaInfo).split("\n");
|
|
44
|
+
|
|
45
|
+// Text acctID = new Text(acctFields[0]);
|
|
46
|
+// Text name = new Text(acctFields[1]);
|
|
47
|
+// Text email = new Text(acctFields[2]);
|
|
48
|
+// Text balance = new Text(acctFields[3]);
|
|
49
|
+
|
|
50
|
+// grid.setAlignment(Pos.CENTER_LEFT);
|
|
51
|
+// grid.setHgap(10);
|
|
52
|
+// grid.setVgap(10);
|
|
53
|
+// Text gridTitle = new Text("Your account details");
|
|
54
|
+// gridTitle.setFont(Font.font("Times New Roman", FontWeight.SEMI_BOLD, 14));
|
|
55
|
+// grid.add(gridTitle, 0, 0, 2, 1);
|
|
56
|
+
|
|
57
|
+// grid.add(acctID,1,1);
|
|
58
|
+// grid.add(name,1,2);
|
|
59
|
+// grid.add(email,1,3);
|
|
60
|
+// grid.add(balance,1,4);
|
|
61
|
+
|
|
62
|
+// grid.setPadding(new Insets(100,300,250,50));
|
|
63
|
+
|
|
64
|
+ flowpane.getChildren().add(btnSubmit);
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+ vbox.getChildren().addAll(field, amountField, flowpane, areaInfo); //grid);
|
|
68
|
+ return vbox;
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ private Parent createContent2(){
|
|
72
|
+ FlowPane flowpane = new FlowPane();
|
|
73
|
+ Text areaInfo = new Text();
|
|
74
|
+ areaInfo.setVisible(true);
|
|
75
|
+ amountField.setPromptText("Enter amounts");
|
|
76
|
+ areaInfo.setText(cashMachine.toString());
|
|
77
|
+
|
|
78
|
+ VBox vbox = new VBox(10);
|
|
79
|
+ vbox.setPrefSize(600, 600);
|
35
|
80
|
|
36
|
81
|
Button btnDeposit = new Button("Deposit");
|
37
|
82
|
btnDeposit.setOnAction(e -> {
|
38
|
|
- int amount = Integer.parseInt(field.getText());
|
|
83
|
+ double amount = Integer.parseInt(amountField.getText());
|
39
|
84
|
cashMachine.deposit(amount);
|
40
|
85
|
|
41
|
86
|
areaInfo.setText(cashMachine.toString());
|
|
87
|
+
|
42
|
88
|
});
|
43
|
89
|
|
|
90
|
+
|
44
|
91
|
Button btnWithdraw = new Button("Withdraw");
|
45
|
92
|
btnWithdraw.setOnAction(e -> {
|
46
|
|
- int amount = Integer.parseInt(field.getText());
|
|
93
|
+ double amount = Integer.parseInt(amountField.getText());
|
47
|
94
|
cashMachine.withdraw(amount);
|
48
|
95
|
|
49
|
96
|
areaInfo.setText(cashMachine.toString());
|
|
@@ -56,18 +103,16 @@ public class CashMachineApp extends Application {
|
56
|
103
|
areaInfo.setText(cashMachine.toString());
|
57
|
104
|
});
|
58
|
105
|
|
59
|
|
- FlowPane flowpane = new FlowPane();
|
60
|
|
-
|
61
|
|
- flowpane.getChildren().add(btnSubmit);
|
62
|
106
|
flowpane.getChildren().add(btnDeposit);
|
63
|
107
|
flowpane.getChildren().add(btnWithdraw);
|
64
|
108
|
flowpane.getChildren().add(btnExit);
|
65
|
|
- vbox.getChildren().addAll(field, flowpane, areaInfo);
|
|
109
|
+
|
|
110
|
+ vbox.getChildren().addAll(amountField, flowpane, areaInfo); //grid);
|
66
|
111
|
return vbox;
|
67
|
112
|
}
|
68
|
|
-
|
69
|
113
|
@Override
|
70
|
114
|
public void start(Stage stage) throws Exception {
|
|
115
|
+ stage.setTitle("Cash Machine");
|
71
|
116
|
stage.setScene(new Scene(createContent()));
|
72
|
117
|
stage.show();
|
73
|
118
|
}
|