|
|
@@ -1,7 +1,142 @@
|
|
1
|
1
|
package com.zipcodewilmington.bankaccountlab;
|
|
2
|
2
|
|
|
|
3
|
+import com.sun.tools.javac.comp.Check;
|
|
|
4
|
+import sun.applet.Main;
|
|
|
5
|
+
|
|
|
6
|
+import java.util.Scanner;
|
|
|
7
|
+
|
|
3
|
8
|
/**
|
|
4
|
9
|
* Created by leon on 1/10/18.
|
|
5
|
10
|
*/
|
|
|
11
|
+
|
|
6
|
12
|
public class MainApplication {
|
|
|
13
|
+
|
|
|
14
|
+ private String name;
|
|
|
15
|
+ private String email;
|
|
|
16
|
+ private String address;
|
|
|
17
|
+ private int pin;
|
|
|
18
|
+ private boolean runCommandCenter;
|
|
|
19
|
+ private CheckingAccount checkingAccount;
|
|
|
20
|
+ private BusinessAccount businessAccount;
|
|
|
21
|
+ private SavingsAccount savingsAccount;
|
|
|
22
|
+
|
|
|
23
|
+
|
|
|
24
|
+
|
|
|
25
|
+
|
|
|
26
|
+ Atm atm = new Atm();
|
|
|
27
|
+
|
|
|
28
|
+ public void main(String[] vv) {
|
|
|
29
|
+
|
|
|
30
|
+ while(runCommandCenter){
|
|
|
31
|
+ commandCenter();
|
|
|
32
|
+ }
|
|
|
33
|
+
|
|
|
34
|
+ System.out.println("Baller ATM only...");
|
|
|
35
|
+ MainApplication mainApplication = new MainApplication(name, email, address, pin);
|
|
|
36
|
+
|
|
|
37
|
+ }
|
|
|
38
|
+
|
|
|
39
|
+
|
|
|
40
|
+ public MainApplication(String name, String email, String address, int pin) {
|
|
|
41
|
+
|
|
|
42
|
+ long accountNumber = Math.round(Math.random() * 999999999);
|
|
|
43
|
+ double balance = 00000.00;
|
|
|
44
|
+
|
|
|
45
|
+ createBusinessAccount(name, email, address, pin, accountNumber, balance);
|
|
|
46
|
+ createSavingsAccount(name, email, address, pin, accountNumber, balance);
|
|
|
47
|
+ createCheckingAccount(name, email, address, pin, accountNumber, balance);
|
|
|
48
|
+
|
|
|
49
|
+
|
|
|
50
|
+ }
|
|
|
51
|
+
|
|
|
52
|
+ public void commandCenter(){
|
|
|
53
|
+
|
|
|
54
|
+ Scanner scanner = new Scanner(System.in);
|
|
|
55
|
+
|
|
|
56
|
+ System.out.println("Choose a command");
|
|
|
57
|
+ System.out.println("'1' - Get the balance of your Checking Account \n'2' - Get the balance of your Savings Account \n'3' - Get balance of your Business Account\n'4' - Deposit money to your Checking Account\n'5' - Deposit money to your Savings Account\n'6' - Deposit money to your Business Account\n'7' - Withdraw money from your Checking Account\n'8' - Withdraw money from your Savings Account\n'9' - Withdraw money from your Business Account\n'10' - Change the pin of your accounts\n'11' - Transfer funds between accounts");
|
|
|
58
|
+ int userInput = scanner.nextInt();
|
|
|
59
|
+
|
|
|
60
|
+ switch(userInput){
|
|
|
61
|
+ case 1:
|
|
|
62
|
+ System.out.println("Your Checking Account balance is: " + checkingAccount.getBalance());
|
|
|
63
|
+ break;
|
|
|
64
|
+
|
|
|
65
|
+ case 2:
|
|
|
66
|
+ System.out.println("Your Savings Account balance is: " + savingsAccount.getBalance());
|
|
|
67
|
+ break;
|
|
|
68
|
+
|
|
|
69
|
+ case 3:
|
|
|
70
|
+ System.out.println("Your Business Account balance is: " + businessAccount.getBalance());
|
|
|
71
|
+ break;
|
|
|
72
|
+
|
|
|
73
|
+ case 4:
|
|
|
74
|
+ System.out.println("How much money would you like to deposit into your Checking Account?");
|
|
|
75
|
+ atm.depositMoney(checkingAccount, scanner.nextDouble());
|
|
|
76
|
+ System.out.println("Money deposited.");
|
|
|
77
|
+ break;
|
|
|
78
|
+
|
|
|
79
|
+ case 5:
|
|
|
80
|
+ System.out.println("How much money would you like to deposit into your Savings Account?");
|
|
|
81
|
+ atm.depositMoney(savingsAccount, scanner.nextDouble());
|
|
|
82
|
+ System.out.println("Money deposited.");
|
|
|
83
|
+ break;
|
|
|
84
|
+
|
|
|
85
|
+ case 6:
|
|
|
86
|
+ System.out.println("How much money would you like to deposit into your Business Account?");
|
|
|
87
|
+ atm.depositMoney(businessAccount, scanner.nextDouble());
|
|
|
88
|
+ System.out.println("Money deposited.");
|
|
|
89
|
+ break;
|
|
|
90
|
+
|
|
|
91
|
+ case 7:
|
|
|
92
|
+ System.out.println("How much money would you like to withdraw from your Checking Account?");
|
|
|
93
|
+ atm.withdrawMoney(checkingAccount, scanner.nextDouble());
|
|
|
94
|
+ System.out.println("Money withdrawn.");
|
|
|
95
|
+ break;
|
|
|
96
|
+
|
|
|
97
|
+ case 8:
|
|
|
98
|
+ System.out.println("How much money would you like to withdraw from your Savings Account?");
|
|
|
99
|
+ atm.withdrawMoney(savingsAccount, scanner.nextDouble());
|
|
|
100
|
+ System.out.println("Money withdrawn.");
|
|
|
101
|
+ break;
|
|
|
102
|
+
|
|
|
103
|
+ case 9:
|
|
|
104
|
+ System.out.println("How much money would you like to withdraw from your Business Account?");
|
|
|
105
|
+ atm.withdrawMoney(businessAccount, scanner.nextDouble());
|
|
|
106
|
+ System.out.println("Money withdrawn");
|
|
|
107
|
+ break;
|
|
|
108
|
+
|
|
|
109
|
+ case 10:
|
|
|
110
|
+ System.out.println("Enter a new pin number.");
|
|
|
111
|
+ atm.changePin(businessAccount, scanner.nextInt());
|
|
|
112
|
+ //might have to change all of the pin number individually...
|
|
|
113
|
+
|
|
|
114
|
+ }
|
|
|
115
|
+
|
|
|
116
|
+ }
|
|
|
117
|
+
|
|
|
118
|
+
|
|
|
119
|
+
|
|
|
120
|
+
|
|
|
121
|
+
|
|
|
122
|
+ public CheckingAccount createCheckingAccount(String name, String email, String address, int pin, long accountNumber, double balance){
|
|
|
123
|
+ CheckingAccount checkingAccount = new CheckingAccount(name, email, address, pin, accountNumber, balance);
|
|
|
124
|
+ this.checkingAccount = checkingAccount;
|
|
|
125
|
+ return this.checkingAccount;
|
|
|
126
|
+
|
|
|
127
|
+ }
|
|
|
128
|
+
|
|
|
129
|
+ public BusinessAccount createBusinessAccount(String name, String email, String address, int pin, long accountNumber, double balance){
|
|
|
130
|
+ BusinessAccount businessAccount = new BusinessAccount(name, email, address, pin, accountNumber, balance);
|
|
|
131
|
+ this.businessAccount = businessAccount;
|
|
|
132
|
+ return this.businessAccount;
|
|
|
133
|
+
|
|
|
134
|
+ }
|
|
|
135
|
+
|
|
|
136
|
+ public SavingsAccount createSavingsAccount(String name, String email, String address, int pin, long accountNumber, double balance){
|
|
|
137
|
+ SavingsAccount savingsAccount = new SavingsAccount(name, email, address, pin, accountNumber, balance);
|
|
|
138
|
+ this.savingsAccount = savingsAccount;
|
|
|
139
|
+ return this.savingsAccount;
|
|
|
140
|
+
|
|
|
141
|
+ }
|
|
7
|
142
|
}
|