|
@@ -1,5 +1,7 @@
|
1
|
1
|
package rocks.zipcode.atm;
|
2
|
2
|
|
|
3
|
+import javafx.geometry.Pos;
|
|
4
|
+import javafx.scene.layout.GridPane;
|
3
|
5
|
import rocks.zipcode.atm.bank.Bank;
|
4
|
6
|
import javafx.application.Application;
|
5
|
7
|
import javafx.scene.Parent;
|
|
@@ -7,63 +9,78 @@ import javafx.scene.Scene;
|
7
|
9
|
import javafx.scene.control.Button;
|
8
|
10
|
import javafx.scene.control.TextArea;
|
9
|
11
|
import javafx.scene.control.TextField;
|
10
|
|
-import javafx.scene.layout.VBox;
|
11
|
12
|
import javafx.stage.Stage;
|
12
|
|
-import javafx.scene.layout.FlowPane;
|
13
|
13
|
|
14
|
14
|
/**
|
15
|
15
|
* @author ZipCodeWilmington
|
16
|
16
|
*/
|
17
|
17
|
public class CashMachineApp extends Application {
|
18
|
18
|
|
19
|
|
- private TextField field = new TextField();
|
20
|
19
|
private CashMachine cashMachine = new CashMachine(new Bank());
|
21
|
20
|
|
|
21
|
+ private TextField setAccountIdField = new TextField();
|
|
22
|
+ // private TextField setDeposit = new TextField();
|
|
23
|
+ // private TextField setAccountIdField = new TextField();
|
|
24
|
+ // private TextField setAccountIdField = new TextField();
|
|
25
|
+
|
22
|
26
|
private Parent createContent() {
|
23
|
|
- VBox vbox = new VBox(10);
|
24
|
|
- vbox.setPrefSize(600, 600);
|
|
27
|
+ setAccountIdField.setMinSize(220, 40);
|
|
28
|
+ // seDeposit.setMinSize(220, 40);
|
|
29
|
+ // setAccountIdField.setMinSize(220, 40);
|
|
30
|
+ // setAccountIdField.setMinSize(220, 40);
|
|
31
|
+
|
|
32
|
+ GridPane gridPane = new GridPane();
|
|
33
|
+ gridPane.setPrefSize(600, 400);
|
|
34
|
+ gridPane.setAlignment(Pos.BASELINE_LEFT);
|
25
|
35
|
|
26
|
36
|
TextArea areaInfo = new TextArea();
|
|
37
|
+ areaInfo.setMaxSize(220, 160);
|
|
38
|
+
|
27
|
39
|
|
28
|
40
|
Button btnSubmit = new Button("Set Account ID");
|
|
41
|
+ btnSubmit.setMinSize(220, 40);
|
29
|
42
|
btnSubmit.setOnAction(e -> {
|
30
|
|
- int id = Integer.parseInt(field.getText());
|
|
43
|
+ int id = Integer.parseInt(setAccountIdField.getText());
|
31
|
44
|
cashMachine.login(id);
|
32
|
45
|
|
33
|
46
|
areaInfo.setText(cashMachine.toString());
|
34
|
47
|
});
|
35
|
48
|
|
36
|
49
|
Button btnDeposit = new Button("Deposit");
|
|
50
|
+ btnDeposit.setMinSize(220, 40);
|
37
|
51
|
btnDeposit.setOnAction(e -> {
|
38
|
|
- int amount = Integer.parseInt(field.getText());
|
|
52
|
+ int amount = Integer.parseInt(setAccountIdField.getText());
|
39
|
53
|
cashMachine.deposit(amount);
|
40
|
54
|
|
41
|
55
|
areaInfo.setText(cashMachine.toString());
|
42
|
56
|
});
|
43
|
57
|
|
44
|
58
|
Button btnWithdraw = new Button("Withdraw");
|
|
59
|
+ btnWithdraw.setMinSize(220, 40);
|
45
|
60
|
btnWithdraw.setOnAction(e -> {
|
46
|
|
- int amount = Integer.parseInt(field.getText());
|
|
61
|
+ int amount = Integer.parseInt(setAccountIdField.getText());
|
47
|
62
|
cashMachine.withdraw(amount);
|
48
|
63
|
|
49
|
64
|
areaInfo.setText(cashMachine.toString());
|
50
|
65
|
});
|
51
|
66
|
|
52
|
67
|
Button btnExit = new Button("Exit");
|
|
68
|
+ btnExit.setMinSize(220, 40);
|
53
|
69
|
btnExit.setOnAction(e -> {
|
54
|
70
|
cashMachine.exit();
|
55
|
71
|
|
56
|
72
|
areaInfo.setText(cashMachine.toString());
|
57
|
73
|
});
|
58
|
74
|
|
59
|
|
- FlowPane flowpane = new FlowPane();
|
60
|
75
|
|
61
|
|
- 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);
|
66
|
|
- return vbox;
|
|
76
|
+ GridPane.setConstraints(btnSubmit, 0, 0);
|
|
77
|
+ GridPane.setConstraints(btnDeposit, 0, 1);
|
|
78
|
+ GridPane.setConstraints(btnWithdraw, 0, 2);
|
|
79
|
+ GridPane.setConstraints(btnExit, 0, 3);
|
|
80
|
+ GridPane.setConstraints(setAccountIdField, 1, 0);
|
|
81
|
+ GridPane.setConstraints(areaInfo, 1, 4);
|
|
82
|
+ gridPane.getChildren().addAll(btnSubmit, btnDeposit, btnWithdraw, btnExit, setAccountIdField, areaInfo);
|
|
83
|
+ return gridPane;
|
67
|
84
|
}
|
68
|
85
|
|
69
|
86
|
@Override
|