|
@@ -10,35 +10,38 @@ import javafx.scene.control.Button;
|
10
|
10
|
import javafx.scene.control.TextArea;
|
11
|
11
|
import javafx.scene.control.TextField;
|
12
|
12
|
import javafx.stage.Stage;
|
|
13
|
+import javafx.scene.paint.Color;
|
13
|
14
|
|
14
|
15
|
/**
|
15
|
16
|
* @author ZipCodeWilmington
|
16
|
17
|
*/
|
17
|
18
|
public class CashMachineApp extends Application {
|
|
19
|
+ Color blue = Color.rgb(0,0,255);
|
|
20
|
+ // Color green = Color.rgb(0,255,255);
|
18
|
21
|
|
19
|
22
|
private CashMachine cashMachine = new CashMachine(new Bank());
|
20
|
23
|
|
21
|
24
|
private TextField setAccountIdField = new TextField();
|
22
|
|
- // private TextField setDeposit = new TextField();
|
23
|
|
- // private TextField setAccountIdField = new TextField();
|
24
|
|
- // private TextField setAccountIdField = new TextField();
|
|
25
|
+ private TextField setDepositField = new TextField();
|
|
26
|
+ private TextField setWithdrawField = new TextField();
|
25
|
27
|
|
26
|
28
|
private Parent createContent() {
|
27
|
|
- setAccountIdField.setMinSize(220, 40);
|
28
|
|
- // seDeposit.setMinSize(220, 40);
|
29
|
|
- // setAccountIdField.setMinSize(220, 40);
|
30
|
|
- // setAccountIdField.setMinSize(220, 40);
|
31
|
|
-
|
|
29
|
+ setAccountIdField.setMinSize(250, 40);
|
|
30
|
+ setDepositField.setMinSize(250, 40);
|
|
31
|
+ setWithdrawField.setMinSize(250, 40);
|
|
32
|
+
|
32
|
33
|
GridPane gridPane = new GridPane();
|
33
|
|
- gridPane.setPrefSize(600, 400);
|
34
|
|
- gridPane.setAlignment(Pos.BASELINE_LEFT);
|
|
34
|
+ gridPane.setPrefSize(500, 400);
|
|
35
|
+ gridPane.setAlignment(Pos.CENTER);
|
|
36
|
+ gridPane.setStyle("-fx-background-color: Green;");
|
35
|
37
|
|
36
|
38
|
TextArea areaInfo = new TextArea();
|
37
|
|
- areaInfo.setMaxSize(220, 160);
|
|
39
|
+ areaInfo.setMaxSize(250, 160);
|
38
|
40
|
|
39
|
41
|
|
40
|
42
|
Button btnSubmit = new Button("Set Account ID");
|
41
|
|
- btnSubmit.setMinSize(220, 40);
|
|
43
|
+ btnSubmit.setMinSize(250, 40);
|
|
44
|
+ btnSubmit.setTextFill(blue);
|
42
|
45
|
btnSubmit.setOnAction(e -> {
|
43
|
46
|
int id = Integer.parseInt(setAccountIdField.getText());
|
44
|
47
|
cashMachine.login(id);
|
|
@@ -47,25 +50,29 @@ public class CashMachineApp extends Application {
|
47
|
50
|
});
|
48
|
51
|
|
49
|
52
|
Button btnDeposit = new Button("Deposit");
|
50
|
|
- btnDeposit.setMinSize(220, 40);
|
|
53
|
+ btnDeposit.setMinSize(250, 40);
|
|
54
|
+ btnDeposit.setTextFill(blue);
|
|
55
|
+//
|
|
56
|
+ // btnDeposit.setDisable(true);
|
51
|
57
|
btnDeposit.setOnAction(e -> {
|
52
|
|
- int amount = Integer.parseInt(setAccountIdField.getText());
|
|
58
|
+ int amount = Integer.parseInt(setDepositField.getText());
|
53
|
59
|
cashMachine.deposit(amount);
|
54
|
|
-
|
55
|
60
|
areaInfo.setText(cashMachine.toString());
|
56
|
61
|
});
|
57
|
62
|
|
58
|
63
|
Button btnWithdraw = new Button("Withdraw");
|
59
|
|
- btnWithdraw.setMinSize(220, 40);
|
|
64
|
+ btnWithdraw.setMinSize(250, 40);
|
|
65
|
+ btnWithdraw.setTextFill(blue);
|
60
|
66
|
btnWithdraw.setOnAction(e -> {
|
61
|
|
- int amount = Integer.parseInt(setAccountIdField.getText());
|
|
67
|
+ int amount = Integer.parseInt(setWithdrawField.getText());
|
62
|
68
|
cashMachine.withdraw(amount);
|
63
|
69
|
|
64
|
70
|
areaInfo.setText(cashMachine.toString());
|
65
|
71
|
});
|
66
|
72
|
|
67
|
73
|
Button btnExit = new Button("Exit");
|
68
|
|
- btnExit.setMinSize(220, 40);
|
|
74
|
+ btnExit.setMinSize(250, 160);
|
|
75
|
+ btnExit.setTextFill(blue);
|
69
|
76
|
btnExit.setOnAction(e -> {
|
70
|
77
|
cashMachine.exit();
|
71
|
78
|
|
|
@@ -78,17 +85,30 @@ public class CashMachineApp extends Application {
|
78
|
85
|
GridPane.setConstraints(btnWithdraw, 0, 2);
|
79
|
86
|
GridPane.setConstraints(btnExit, 0, 3);
|
80
|
87
|
GridPane.setConstraints(setAccountIdField, 1, 0);
|
81
|
|
- GridPane.setConstraints(areaInfo, 1, 4);
|
82
|
|
- gridPane.getChildren().addAll(btnSubmit, btnDeposit, btnWithdraw, btnExit, setAccountIdField, areaInfo);
|
|
88
|
+ GridPane.setConstraints(setDepositField, 1, 1);
|
|
89
|
+ GridPane.setConstraints(setWithdrawField,1, 2);
|
|
90
|
+ GridPane.setConstraints(areaInfo, 1, 3);
|
|
91
|
+ gridPane.getChildren().addAll(btnSubmit, btnDeposit, btnWithdraw, btnExit,
|
|
92
|
+ setAccountIdField, setDepositField, setWithdrawField, areaInfo);
|
83
|
93
|
return gridPane;
|
84
|
94
|
}
|
85
|
95
|
|
86
|
96
|
@Override
|
87
|
97
|
public void start(Stage stage) throws Exception {
|
88
|
98
|
stage.setScene(new Scene(createContent()));
|
|
99
|
+ stage.setTitle("Zip Code ATM");
|
89
|
100
|
stage.show();
|
90
|
101
|
}
|
91
|
102
|
|
|
103
|
+ public boolean isValidId(int id){
|
|
104
|
+ if (cashMachine.isValidId(id)) {
|
|
105
|
+ return true;
|
|
106
|
+ }
|
|
107
|
+ else {
|
|
108
|
+ return false;
|
|
109
|
+ }
|
|
110
|
+ }
|
|
111
|
+
|
92
|
112
|
public static void main(String[] args) {
|
93
|
113
|
launch(args);
|
94
|
114
|
}
|