|
@@ -1,138 +1,179 @@
|
1
|
|
-//package rocks.zipcode.atm;
|
2
|
|
-//
|
3
|
|
-//import javafx.geometry.Insets;
|
4
|
|
-//import javafx.geometry.Pos;
|
5
|
|
-//import javafx.scene.control.*;
|
6
|
|
-//import javafx.scene.layout.GridPane;
|
7
|
|
-//import javafx.scene.text.Text;
|
8
|
|
-//import rocks.zipcode.atm.bank.Bank;
|
9
|
|
-//import javafx.application.Application;
|
10
|
|
-//import javafx.scene.Parent;
|
11
|
|
-//import javafx.scene.Scene;
|
12
|
|
-//import javafx.scene.layout.VBox;
|
13
|
|
-//import javafx.stage.Stage;
|
14
|
|
-//import javafx.scene.layout.FlowPane;
|
15
|
|
-//
|
16
|
|
-//import java.util.ArrayList;
|
17
|
|
-//
|
18
|
|
-///**
|
19
|
|
-// * @author ZipCodeWilmington
|
20
|
|
-// */
|
21
|
|
-//public class CashMachineApp extends Application {
|
22
|
|
-//
|
23
|
|
-// private TextField field = new TextField();
|
24
|
|
-// private CashMachine cashMachine = new CashMachine(new Bank());
|
25
|
|
-//
|
26
|
|
-// private Parent createContent() {
|
27
|
|
-// field.setFocusTraversable(false);
|
28
|
|
-// field.setPromptText("Enter Account ID");
|
29
|
|
-// FlowPane flowpane = new FlowPane();
|
30
|
|
-// VBox vbox = new VBox(10);
|
31
|
|
-// vbox.setPrefSize(600, 600);
|
32
|
|
-//
|
33
|
|
-// TextArea areaInfo = new TextArea();
|
34
|
|
-//
|
35
|
|
-// GridPane gridPane = new GridPane();
|
36
|
|
-// gridPane.setAlignment(Pos.CENTER_LEFT);
|
37
|
|
-// gridPane.setVgap(5);
|
38
|
|
-// gridPane.setHgap(5);
|
39
|
|
-// Text account = new Text();
|
40
|
|
-// Text name = new Text();
|
41
|
|
-// Text email = new Text();
|
42
|
|
-// Text balance = new Text();
|
43
|
|
-//
|
44
|
|
-//
|
45
|
|
-// MenuBar menuBar = new MenuBar();
|
46
|
|
-//
|
47
|
|
-// Button btnDeposit = new Button("Deposit");
|
48
|
|
-// btnDeposit.setOnAction(e -> {
|
49
|
|
-// int amount = Integer.parseInt(field.getText());
|
50
|
|
-// cashMachine.deposit(amount);
|
51
|
|
-//
|
52
|
|
-// account.setText(cashMachine.accountIdToString());
|
53
|
|
-// name.setText(cashMachine.nameToString());
|
54
|
|
-// email.setText(cashMachine.emailToString());
|
55
|
|
-// balance.setText(cashMachine.balanceToString());
|
56
|
|
-// });
|
57
|
|
-//
|
58
|
|
-// Button btnWithdraw = new Button("Withdraw");
|
59
|
|
-// btnWithdraw.setOnAction(e -> {
|
60
|
|
-// int amount = Integer.parseInt(field.getText());
|
61
|
|
-// cashMachine.withdraw(amount);
|
62
|
|
-//
|
63
|
|
-// account.setText(cashMachine.accountIdToString());
|
64
|
|
-// name.setText(cashMachine.nameToString());
|
65
|
|
-// email.setText(cashMachine.emailToString());
|
66
|
|
-// balance.setText(cashMachine.balanceToString());
|
67
|
|
-// });
|
68
|
|
-//
|
69
|
|
-// Button btnExit = new Button("Exit");
|
70
|
|
-// btnExit.setOnAction(e -> {
|
71
|
|
-// cashMachine.exit();
|
72
|
|
-// account.setText(cashMachine.accountIdToString());
|
73
|
|
-// name.setText(cashMachine.nameToString());
|
74
|
|
-// email.setText(cashMachine.emailToString());
|
75
|
|
-// balance.setText(cashMachine.balanceToString());
|
76
|
|
-// });
|
77
|
|
-//
|
78
|
|
-// Button btnSubmit = new Button("Login");
|
79
|
|
-// btnSubmit.setOnAction(e -> {
|
80
|
|
-// int id = Integer.parseInt(field.getText());
|
81
|
|
-// cashMachine.login(id);
|
82
|
|
-// account.setText(cashMachine.accountIdToString());
|
83
|
|
-// name.setText(cashMachine.nameToString());
|
84
|
|
-// email.setText(cashMachine.emailToString());
|
85
|
|
-// balance.setText(cashMachine.balanceToString());
|
86
|
|
-// btnDeposit.setVisible(true);
|
87
|
|
-// btnWithdraw.setVisible(true);
|
88
|
|
-// btnExit.setVisible(true);
|
89
|
|
-// menuBar.setVisible(true);
|
90
|
|
-//
|
91
|
|
-//
|
92
|
|
-// });
|
93
|
|
-//
|
94
|
|
-// btnDeposit.setVisible(false);
|
95
|
|
-// btnWithdraw.setVisible(false);
|
96
|
|
-// btnExit.setVisible(false);
|
97
|
|
-// menuBar.setVisible(false);
|
98
|
|
-//
|
99
|
|
-// Menu accountMenu = new Menu("All Accounts");
|
100
|
|
-//
|
101
|
|
-// flowpane.getChildren().add(btnSubmit);
|
102
|
|
-// flowpane.getChildren().add(btnDeposit);
|
103
|
|
-// flowpane.getChildren().add(btnWithdraw);
|
104
|
|
-// flowpane.getChildren().add(btnExit);
|
105
|
|
-// flowpane.getChildren().add(menuBar);
|
106
|
|
-// menuBar.getMenus().add(accountMenu);
|
107
|
|
-//
|
108
|
|
-// ArrayList<String> accountList = cashMachine.listAccounts();
|
109
|
|
-// for(String acct : accountList){
|
110
|
|
-// MenuItem newItem = new MenuItem(acct);
|
111
|
|
-// newItem.setOnAction(e -> {
|
112
|
|
-// field.clear();
|
113
|
|
-// field.setPromptText("Enter Id and click \"Login\"");
|
114
|
|
-// });
|
115
|
|
-//
|
116
|
|
-// accountMenu.getItems().add(newItem);
|
117
|
|
-//
|
118
|
|
-// }
|
119
|
|
-//
|
120
|
|
-// gridPane.setPadding(new Insets(25,25,25,25));
|
121
|
|
-// gridPane.add(account,0,1);
|
122
|
|
-// gridPane.add(name,0,2);
|
123
|
|
-// gridPane.add(email,0,3);
|
124
|
|
-// gridPane.add(balance,0,4);
|
125
|
|
-// vbox.getChildren().addAll(field, flowpane, gridPane);
|
126
|
|
-// return vbox;
|
127
|
|
-// }
|
128
|
|
-//
|
129
|
|
-// @Override
|
130
|
|
-// public void start(Stage stage) throws Exception {
|
131
|
|
-// stage.setScene(new Scene(createContent()));
|
132
|
|
-// stage.show();
|
133
|
|
-// }
|
134
|
|
-//
|
135
|
|
-// public static void main(String[] args) {
|
136
|
|
-// launch(args);
|
137
|
|
-// }
|
138
|
|
-//}
|
|
1
|
+package rocks.zipcode.atm;
|
|
2
|
+
|
|
3
|
+import javafx.application.Application;
|
|
4
|
+import javafx.geometry.Insets;
|
|
5
|
+import javafx.geometry.Pos;
|
|
6
|
+import javafx.scene.Scene;
|
|
7
|
+import javafx.scene.control.*;
|
|
8
|
+import javafx.scene.layout.FlowPane;
|
|
9
|
+import javafx.scene.layout.GridPane;
|
|
10
|
+import javafx.scene.layout.VBox;
|
|
11
|
+import javafx.scene.paint.Color;
|
|
12
|
+import javafx.scene.text.Font;
|
|
13
|
+import javafx.scene.text.Text;
|
|
14
|
+import javafx.stage.Stage;
|
|
15
|
+import rocks.zipcode.atm.bank.Bank;
|
|
16
|
+
|
|
17
|
+import java.util.ArrayList;
|
|
18
|
+
|
|
19
|
+public class CashMachineApp extends Application {
|
|
20
|
+ CashMachine cashMachine = new CashMachine(new Bank());
|
|
21
|
+ Text account = new Text();
|
|
22
|
+ Text name = new Text();
|
|
23
|
+ Text email = new Text();
|
|
24
|
+ Text balance = new Text();
|
|
25
|
+ Button btnDeposit = new Button("Deposit");
|
|
26
|
+ Button btnWithdraw = new Button("Withdraw");
|
|
27
|
+ Button btnExit = new Button("Logout");
|
|
28
|
+ Button btnSubmit = new Button("Login");
|
|
29
|
+ Button btnClose = new Button("Exit");
|
|
30
|
+ Button btnNewAccount = new Button("New Account");
|
|
31
|
+ TextField name1 = new TextField("Name");
|
|
32
|
+ TextField email1 = new TextField("Email");
|
|
33
|
+ TextField balance1 = new TextField("Balance");
|
|
34
|
+ RadioButton basicAcct = new RadioButton("Basic Account");
|
|
35
|
+ RadioButton premAcct = new RadioButton("Premium Account");
|
|
36
|
+ Button btnSubmit2 = new Button("Create Account");
|
|
37
|
+
|
|
38
|
+ FlowPane fp = new FlowPane();
|
|
39
|
+ FlowPane fp2 = new FlowPane();
|
|
40
|
+ GridPane gp2 = new GridPane();
|
|
41
|
+ VBox vb3 = new VBox();
|
|
42
|
+ VBox vb = new VBox();
|
|
43
|
+ VBox vb2 = new VBox();
|
|
44
|
+ private TextField field = new TextField();
|
|
45
|
+ private TextField field2 = new TextField();
|
|
46
|
+
|
|
47
|
+ public static void main(String[] args) {
|
|
48
|
+ launch(args);
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ @Override
|
|
52
|
+ public void start(Stage primaryStage) {
|
|
53
|
+ field.setFocusTraversable(false);
|
|
54
|
+ field.setPromptText("Enter Account ID");
|
|
55
|
+ field.setPadding(new Insets(5,0,5,0));
|
|
56
|
+ field.setMaxWidth(250);
|
|
57
|
+
|
|
58
|
+ Scene scene1 = new Scene(vb,300,250, Color.BURLYWOOD);
|
|
59
|
+ Scene scene2 = new Scene(vb2,300,250, Color.BURLYWOOD);
|
|
60
|
+ Scene scene3 = new Scene(vb3,300,250, Color.BURLYWOOD);
|
|
61
|
+
|
|
62
|
+ btnSubmit.setOnAction(e -> {
|
|
63
|
+ field.clear();
|
|
64
|
+ int id = Integer.parseInt(field.getText());
|
|
65
|
+ cashMachine.login(id);
|
|
66
|
+ primaryStage.setScene(scene2);
|
|
67
|
+ });
|
|
68
|
+
|
|
69
|
+ btnDeposit.setOnAction(e -> {
|
|
70
|
+ double amount = Integer.parseInt(field2.getText());
|
|
71
|
+ cashMachine.deposit(amount);
|
|
72
|
+
|
|
73
|
+ account.setText(cashMachine.accountIdToString());
|
|
74
|
+ name.setText(cashMachine.nameToString());
|
|
75
|
+ email.setText(cashMachine.emailToString());
|
|
76
|
+ balance.setText(cashMachine.balanceToString());
|
|
77
|
+ });
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+ btnWithdraw.setOnAction(e -> {
|
|
81
|
+ double amount = Integer.parseInt(field2.getText());
|
|
82
|
+ cashMachine.withdraw(amount);
|
|
83
|
+
|
|
84
|
+ account.setText(cashMachine.accountIdToString());
|
|
85
|
+ name.setText(cashMachine.nameToString());
|
|
86
|
+ email.setText(cashMachine.emailToString());
|
|
87
|
+ balance.setText(cashMachine.balanceToString());
|
|
88
|
+ });
|
|
89
|
+
|
|
90
|
+ btnNewAccount.setOnAction(e -> {
|
|
91
|
+ primaryStage.setScene(scene3);
|
|
92
|
+ field2.clear();
|
|
93
|
+ field.clear();
|
|
94
|
+ });
|
|
95
|
+
|
|
96
|
+ btnExit.setOnAction(e -> {
|
|
97
|
+ cashMachine.exit();
|
|
98
|
+ field.clear();
|
|
99
|
+ primaryStage.setScene(scene1);
|
|
100
|
+ });
|
|
101
|
+
|
|
102
|
+ btnClose.setOnAction(e -> {
|
|
103
|
+ System.exit(0);
|
|
104
|
+ }); //add alert box to ask Are you sure??
|
|
105
|
+
|
|
106
|
+ btnSubmit2.setOnAction(e ->{
|
|
107
|
+ name1.clear(); email1.clear(); balance1.clear();
|
|
108
|
+ final ToggleGroup group = new ToggleGroup();
|
|
109
|
+ basicAcct.setToggleGroup(group);
|
|
110
|
+ premAcct.setToggleGroup(group);
|
|
111
|
+ if (basicAcct.isSelected()) {
|
|
112
|
+ cashMachine.newBasicAccount(name1.getText(), email1.getText(), Double.parseDouble(balance1.getText()));
|
|
113
|
+ } else {cashMachine.newPremiumAccount(name1.getText(), email1.getText(), Double.parseDouble(balance1.getText()));
|
|
114
|
+// TextField newId = new TextField("Your account Id is " + cashMachine.accountIdToString());
|
|
115
|
+// newId.setVisible(true);
|
|
116
|
+// cashMachine.login(Integer.parseInt(cashMachine.accountIdToString()));
|
|
117
|
+ btnExit.fire();
|
|
118
|
+ }
|
|
119
|
+ });
|
|
120
|
+
|
|
121
|
+ //scene1 items
|
|
122
|
+ Label zipCloud = new Label("ZipCloud Bank");
|
|
123
|
+ Label phrase = new Label("We Make It Rain");
|
|
124
|
+ zipCloud.setPrefSize(180,60);
|
|
125
|
+ zipCloud.setFont(new Font("Gotham",24));
|
|
126
|
+ zipCloud.setAlignment(Pos.TOP_CENTER);
|
|
127
|
+ phrase.setPrefSize(150,20);
|
|
128
|
+ phrase.setPadding(new Insets(0,0,20,0));
|
|
129
|
+ phrase.setAlignment(Pos.TOP_CENTER);
|
|
130
|
+
|
|
131
|
+ fp.getChildren().addAll(btnSubmit,btnClose);
|
|
132
|
+ fp.setPadding(new Insets(0,25,0,25));
|
|
133
|
+ vb.getChildren().addAll(zipCloud, phrase, field,fp);
|
|
134
|
+ vb.setAlignment(Pos.CENTER);
|
|
135
|
+ vb.setStyle("-fx-background-color: burlywood; -fx-padding: 2; -fx-border-color: dimgrey; -fx-border-style: solid; -fx-border-width: 2; -fx-vgap: 5");
|
|
136
|
+
|
|
137
|
+ //scene2items
|
|
138
|
+ Label zipCloud2 = new Label("ZipCloud Bank");
|
|
139
|
+ zipCloud2.setPrefSize(180,80);
|
|
140
|
+ zipCloud2.setFont(new Font("Gotham",24));
|
|
141
|
+ zipCloud2.setAlignment(Pos.TOP_CENTER);
|
|
142
|
+
|
|
143
|
+ Menu accountMenu = new Menu("Switch Accounts");
|
|
144
|
+ MenuBar menuBar = new MenuBar();
|
|
145
|
+ menuBar.getMenus().add(accountMenu);
|
|
146
|
+ ArrayList<String> accountList = cashMachine.listAccounts();
|
|
147
|
+ for(String acct : accountList) {
|
|
148
|
+ MenuItem newItem = new MenuItem(acct);
|
|
149
|
+ newItem.setOnAction(e -> btnExit.fire());
|
|
150
|
+ accountMenu.getItems().add(newItem);
|
|
151
|
+ }
|
|
152
|
+ fp2.getChildren().addAll(btnDeposit,btnWithdraw,btnNewAccount,btnExit, btnClose);
|
|
153
|
+ fp2.setAlignment(Pos.CENTER);
|
|
154
|
+
|
|
155
|
+ gp2.setVgap(.1);
|
|
156
|
+ gp2.setHgap(10);
|
|
157
|
+ gp2.setPadding(new Insets(25,25,25,25));
|
|
158
|
+ gp2.setOpacity(20);
|
|
159
|
+ gp2.setAlignment(Pos.BOTTOM_CENTER);
|
|
160
|
+ gp2.setPrefSize(100,50);
|
|
161
|
+ gp2.setStyle("-fx-font-size: 12; -fx-font-smoothing-type: LCD; -fx-font-family: fantasy");
|
|
162
|
+
|
|
163
|
+ gp2.add(account,0,0);
|
|
164
|
+ gp2.add(name,0,1);
|
|
165
|
+ gp2.add(email,1,0);
|
|
166
|
+ gp2.add(balance,1,1);
|
|
167
|
+ vb2.getChildren().addAll(menuBar, zipCloud2, field2,fp2,gp2);
|
|
168
|
+ vb2.setAlignment(Pos.BOTTOM_CENTER);
|
|
169
|
+ vb2.setStyle("-fx-background-color: burlywood; -fx-padding: 2; -fx-border-color: dimgrey; -fx-border-style: solid; -fx-border-width: 2; -fx-vgap: 5");
|
|
170
|
+
|
|
171
|
+ //scene3items
|
|
172
|
+ vb3.getChildren().addAll(name1,email1,balance1,basicAcct,premAcct,btnSubmit2);
|
|
173
|
+ vb3.setStyle("-fx-background-color: burlywood; -fx-padding: 2; -fx-border-color: dimgrey; -fx-border-style: solid; -fx-border-width: 2; -fx-vgap: 5");
|
|
174
|
+
|
|
175
|
+ primaryStage.setTitle("Zip Cloud Bank");
|
|
176
|
+ primaryStage.setScene(scene1);
|
|
177
|
+ primaryStage.show();
|
|
178
|
+ }
|
|
179
|
+}
|