Pārlūkot izejas kodu

checkpoint. CashMachine2

Demetrius Murray 6 gadus atpakaļ
vecāks
revīzija
8996cbc207

Binārs
src/main/java/rocks/zipcode/.DS_Store Parādīt failu


+ 114
- 0
src/main/java/rocks/zipcode/atm/CashMachine2.java Parādīt failu

@@ -0,0 +1,114 @@
1
+package rocks.zipcode.atm;
2
+
3
+import javafx.application.Application;
4
+import javafx.geometry.Insets;
5
+import javafx.scene.Scene;
6
+import javafx.scene.control.Button;
7
+import javafx.scene.control.TextField;
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.Text;
13
+import javafx.stage.Stage;
14
+import rocks.zipcode.atm.bank.Bank;
15
+
16
+public class CashMachine2 extends Application {
17
+    CashMachine cashMachine = new CashMachine(new Bank());
18
+    Text account = new Text();
19
+    Text name = new Text();
20
+    Text email = new Text();
21
+    Text balance = new Text();
22
+    Button btnDeposit = new Button("Deposit");
23
+    Button btnWithdraw = new Button("Withdraw");
24
+    Button btnExit = new Button("Logout");
25
+    Button btnSubmit = new Button("Login");
26
+    Button btnClose = new Button("Exit");
27
+    FlowPane fp = new FlowPane();
28
+    FlowPane fp2 = new FlowPane();
29
+    GridPane gp2 = new GridPane();
30
+    VBox vb = new VBox();
31
+    VBox vb2 = new VBox();
32
+    private TextField field = new TextField();
33
+    private TextField field2 = new TextField();
34
+
35
+    public static void main(String[] args) {
36
+        launch(args);
37
+    }
38
+
39
+    @Override
40
+    public void start(Stage primaryStage) {
41
+        field.setFocusTraversable(false);
42
+        field.setPromptText("Enter Account ID");
43
+
44
+        Scene scene1 = new Scene(vb,300,250, Color.BURLYWOOD);
45
+        Scene scene2 = new Scene(vb2,300,250, Color.BURLYWOOD);
46
+
47
+        btnSubmit.setOnAction(e -> {
48
+            int id = Integer.parseInt(field.getText());
49
+            cashMachine.login(id);
50
+            primaryStage.setScene(scene2);
51
+//            account.setText(cashMachine.accountIdToString());
52
+//            name.setText(cashMachine.nameToString());
53
+//            email.setText(cashMachine.emailToString());
54
+//            balance.setText(cashMachine.balanceToString());
55
+//            btnDeposit.setVisible(true);
56
+//            btnWithdraw.setVisible(true);
57
+//            btnExit.setVisible(true);
58
+            //menuBar.setVisible(true);
59
+        });
60
+
61
+        btnDeposit.setOnAction(e -> {
62
+            double amount = Integer.parseInt(field2.getText());
63
+            cashMachine.deposit(amount);
64
+
65
+            account.setText(cashMachine.accountIdToString());
66
+            name.setText(cashMachine.nameToString());
67
+            email.setText(cashMachine.emailToString());
68
+            balance.setText(cashMachine.balanceToString());
69
+        });
70
+
71
+
72
+        btnWithdraw.setOnAction(e -> {
73
+            double amount = Integer.parseInt(field2.getText());
74
+            cashMachine.withdraw(amount);
75
+
76
+            account.setText(cashMachine.accountIdToString());
77
+            name.setText(cashMachine.nameToString());
78
+            email.setText(cashMachine.emailToString());
79
+            balance.setText(cashMachine.balanceToString());
80
+        });
81
+
82
+        btnExit.setOnAction(e -> {
83
+            cashMachine.exit();
84
+            primaryStage.setScene(scene1);
85
+        });
86
+
87
+        btnClose.setOnAction(e -> {
88
+            System.exit(0);
89
+        }); //add alert box to ask Are you sure??
90
+
91
+        gp2.setVgap(.5);
92
+        gp2.setPadding(new Insets(25,25,25,25));
93
+        gp2.setOpacity(50);
94
+        gp2.setStyle(" -fx-opacity: 10; -fx-padding: 2; -fx-border-color: dimgrey; -fx-border-style: solid; -fx-border-width: 2; -fx-vgap: 5");
95
+        //scene1 items
96
+        fp.getChildren().addAll(btnSubmit,btnExit);
97
+        vb.getChildren().addAll(field,fp);
98
+        //scene2items
99
+        fp2.getChildren().addAll(btnDeposit,btnWithdraw,btnExit);
100
+        gp2.add(account,1,0);
101
+        gp2.add(name,1,1);
102
+        gp2.add(email,1,2);
103
+        gp2.add(balance,1,3);
104
+        vb2.getChildren().addAll(field2,fp2,gp2);
105
+
106
+
107
+//        fp.getChildren().add(menuBar);
108
+
109
+
110
+        primaryStage.setTitle("Primary");
111
+        primaryStage.setScene(scene1);
112
+        primaryStage.show();
113
+    }
114
+}

+ 138
- 138
src/main/java/rocks/zipcode/atm/CashMachineApp.java Parādīt failu

@@ -1,138 +1,138 @@
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.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
+//}