Browse Source

Buttons disabled until log in

Lauren Green 6 years ago
parent
commit
0386401ee8

+ 16
- 6
src/main/java/rocks/zipcode/atm/CashMachineApp.java View File

@@ -30,16 +30,11 @@ public class CashMachineApp extends Application {
30 30
 
31 31
         TextArea areaInfo = new TextArea();
32 32
 
33
-        Button btnSubmit = new Button("Enter");
34
-        btnSubmit.setOnAction(e -> {
35
-            int id = Integer.parseInt(field.getText());
36
-            cashMachine.login(id);
37 33
 
38
-            areaInfo.setText(cashMachine.toString());
39
-        });
40 34
 
41 35
         //Make Button Do something.
42 36
         Button btnNewAccount = new Button("Setup New Account");
37
+        btnNewAccount.setDisable(true);
43 38
        /*
44 39
         btnSubmit.setOnAction(e -> {
45 40
 
@@ -47,6 +42,7 @@ public class CashMachineApp extends Application {
47 42
 */
48 43
 
49 44
         Button btnDeposit = new Button("Deposit");
45
+        btnDeposit.setDisable(true);
50 46
         btnDeposit.setOnAction(e -> {
51 47
             float amount = Float.parseFloat(field2.getText());
52 48
             cashMachine.deposit(amount);
@@ -54,7 +50,9 @@ public class CashMachineApp extends Application {
54 50
             areaInfo.setText(cashMachine.toString());
55 51
         });
56 52
 
53
+
57 54
         Button btnWithdraw = new Button("Withdraw");
55
+        btnWithdraw.setDisable(true);
58 56
         btnWithdraw.setOnAction(e -> {
59 57
             float amount = Float.parseFloat(field2.getText());
60 58
             cashMachine.withdraw(amount);
@@ -68,6 +66,18 @@ public class CashMachineApp extends Application {
68 66
             field.clear();
69 67
             field2.clear();
70 68
             areaInfo.clear();
69
+            btnDeposit.setDisable(true);
70
+            btnWithdraw.setDisable(true);
71
+        });
72
+
73
+        Button btnSubmit = new Button("Enter");
74
+        btnSubmit.setOnAction(e -> {
75
+            int id = Integer.parseInt(field.getText());
76
+            cashMachine.login(id);
77
+
78
+            areaInfo.setText(cashMachine.toString());
79
+            btnDeposit.setDisable(false);
80
+            btnWithdraw.setDisable(false);
71 81
         });
72 82
 
73 83
         FlowPane flowpane = new FlowPane();

+ 1
- 1
src/main/java/rocks/zipcode/atm/bank/AccountData.java View File

@@ -39,6 +39,6 @@ public final class AccountData {
39 39
         return "Account id: " + id + '\n' +
40 40
                 "Name: " + name + '\n' +
41 41
                 "Email: " + email + '\n' +
42
-                "Balance: " + String.format("%.2f", balance);
42
+                "Balance: " + String.format("%,.2f", balance);
43 43
     }
44 44
 }

+ 5
- 1
src/main/java/rocks/zipcode/atm/bank/Bank.java View File

@@ -17,7 +17,11 @@ public class Bank {
17 17
 
18 18
     public Bank() {
19 19
         accounts.put(1000, new BasicAccount(new AccountData(
20
-                1000, "Nick Foles", "liimvp@gmail.com", 500
20
+                1000, "Nick Foles", "LIImvp@gmail.com", 500
21
+        )));
22
+
23
+        accounts.put(1010, new BasicAccount(new AccountData(
24
+                1000, "Dan Green", "dgreen@gmail.com", 100000
21 25
         )));
22 26
 
23 27
         accounts.put(2000, new PremiumAccount(new AccountData(