Browse Source

added code that might print a log in alert

mpierse 6 years ago
parent
commit
313de949ca

+ 6
- 1
src/main/java/rocks/zipcode/atm/CashMachine.java View File

@@ -1,5 +1,6 @@
1 1
 package rocks.zipcode.atm;
2 2
 
3
+import javafx.scene.control.Alert;
3 4
 import rocks.zipcode.atm.bank.AccountData;
4 5
 import rocks.zipcode.atm.bank.Bank;
5 6
 
@@ -69,7 +70,11 @@ public class CashMachine {
69 70
                 throw new RuntimeException(errorMessage);
70 71
             }
71 72
         } catch (Exception e) {
72
-            System.out.println("Error: " + e.getMessage());
73
+            Alert alert = new Alert(Alert.AlertType.ERROR);
74
+            alert.setTitle("Overdraw!");
75
+            alert.setHeaderText("Not enough money!");
76
+            alert.setContentText("You do not have enough money in your account to complete this transaction.");
77
+            //System.out.println("Error: " + e.getMessage());
73 78
         }
74 79
     }
75 80
 }

+ 43
- 0
src/main/java/rocks/zipcode/atm/CashMachineApp.java View File

@@ -1,5 +1,14 @@
1 1
 package rocks.zipcode.atm;
2 2
 
3
+import javafx.event.ActionEvent;
4
+import javafx.event.EventHandler;
5
+import javafx.geometry.Insets;
6
+import javafx.geometry.Pos;
7
+import javafx.scene.control.Label;
8
+import javafx.scene.layout.GridPane;
9
+import javafx.scene.layout.HBox;
10
+import javafx.scene.paint.Color;
11
+import javafx.scene.text.Text;
3 12
 import rocks.zipcode.atm.bank.Bank;
4 13
 import javafx.application.Application;
5 14
 import javafx.scene.Parent;
@@ -19,6 +28,40 @@ public class CashMachineApp extends Application {
19 28
     private TextField field = new TextField();
20 29
     private CashMachine cashMachine = new CashMachine(new Bank());
21 30
 
31
+    public void login(Stage primaryStage){
32
+        GridPane grid = new GridPane();
33
+        grid.setAlignment(Pos.CENTER);
34
+        grid.setHgap(10);
35
+        grid.setVgap(10);
36
+        grid.setPadding(new Insets(25, 25, 25, 25));
37
+
38
+        Button btn = new Button("Log in");
39
+        HBox hbButton = new HBox(10);
40
+        hbButton.setAlignment(Pos.BOTTOM_RIGHT);
41
+        hbButton.getChildren().add(btn);
42
+        grid.add(hbButton,1,4);
43
+
44
+        final Text actiontarget = new Text();
45
+        grid.add(actiontarget,1,6);
46
+
47
+        btn.setOnAction(new EventHandler<ActionEvent>() {
48
+            @Override
49
+            public void handle(ActionEvent event) {
50
+                createContent();
51
+
52
+            }
53
+        });
54
+
55
+
56
+        Scene scene = new Scene(grid, 300, 275);
57
+        primaryStage.setScene(scene);
58
+        primaryStage.setTitle("Welcome to Zip Cloud Bank");
59
+        Label userID = new Label("User I.D.");
60
+        grid.add(userID,0,1);
61
+        TextField userTextField = new TextField();
62
+        grid.add(userTextField,1,1);
63
+    }
64
+
22 65
     private Parent createContent() {
23 66
         VBox vbox = new VBox(10);
24 67
         vbox.setPrefSize(600, 600);

+ 7
- 0
src/main/java/rocks/zipcode/atm/bank/Bank.java View File

@@ -20,6 +20,13 @@ public class Bank {
20 20
         accounts.put(2000, new PremiumAccount(new AccountData(
21 21
                 2000, "Example 2", "example2@gmail.com", 200
22 22
         )));
23
+
24
+        accounts.put(3000, new PremiumAccount(new AccountData(
25
+                3000, "Scooby Doo", "scoobs@gmail.com", 50
26
+        )));
27
+        accounts.put(4000, new BasicAccount(new AccountData(
28
+                4000, "Road Runner", "beebbeeb@gmail.com", 2000
29
+        )));
23 30
     }
24 31
 
25 32
     public ActionResult<AccountData> getAccountById(int id) {