-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreditDebitCards.java
More file actions
364 lines (317 loc) · 12.2 KB
/
CreditDebitCards.java
File metadata and controls
364 lines (317 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
import java.util.Scanner;
import java.util.Random;
public class CreditDebitCards {
public static void main(String[] args) {
// TODO Auto-generated method stub
// parameters should be based on other group's code
// OUR CODE SO FAR... IN THE WORKS
//Debit myDebit = new Debit(1000000000, 1, 1234, "Byron", 1111987667890069.0, 420);
// 1111 indicates Bing Bong Byron Bank - otherwise it's a diff bank/card
//System.out.println("Your balance is: $" + myDebit.getBalance());
//myDebit.withdrawDollah();
//myDebit.withdrawDollah();
//myDebit.depositDollah();
//System.out.println(myDebit.getTotalSpent());
//Credit myCredit = new Credit(1000000000, 1234, "Byron", 1111987667890069.0, 420, 2000.00);
}
}
class Debit {
private double balance;
private int RoutingNumber;
private double totalSpent = 0;
private int userPIN;
private double dcNUM;
private int CVV;
private static user abc;
private String userName;
//private double withdrawAmt;
// double depositAmt;
Debit() {
balance = 0.00;
RoutingNumber = 420691234;
dcNUM = 1111123443216969.0;
CVV = 420;
}
Debit(double bal, int num, int PIN, String name, double num2, int numcvv) {
balance = bal;
RoutingNumber = num;
userPIN = PIN;
userName = name;
dcNUM = num2;
CVV = numcvv;
}
Debit(double bal, int num, int PIN, String name, double num2, int numcvv, user Person) {
balance = bal;
RoutingNumber = num;
userPIN = PIN;
userName = name;
dcNUM = num2;
CVV = numcvv;
abc = Person;
}
public double getDCNum() {
return dcNUM;
}
public double getBalance() {
checkRoutingNumber();
checkPIN();
return balance;
}
// FOR ATM
public double getATMBalance() {
return balance;
}
public String getUserName() {
return userName;
}
public void PutInCard() {
System.out.println("Please put in your credit card.");
}
public void setUser(user person) {
abc = person;
}
public boolean checkDebitCardNum() { // checks debit card number AND cvv together
Scanner keyboard = new Scanner(System.in);
System.out.print("Please enter your debit card number for confirmation: ");
double userInput = keyboard.nextDouble();
if (userInput == dcNUM) {
checkCVV();
return true;
} else {
System.out.println("\nIncorrect debit card number, please try again.");
return checkDebitCardNum();
}
}
public boolean checkCVV() {
Scanner keyboard = new Scanner(System.in);
System.out.print("Please enter your CVV (3 digits on the back) for confirmation: ");
int userInput = keyboard.nextInt(); // user's input word
if (userInput == CVV) {
return true;
} else {
System.out.println("Incorrect CVV number, please try again.");
return checkCVV();
}
}
public boolean checkRoutingNumber() {
Scanner keyboard = new Scanner(System.in);
System.out.print("Please enter your routing number for confirmation: ");
int userInput = keyboard.nextInt(); // user's input word
if (userInput == RoutingNumber) {
return true;
} else {
System.out.println("\nIncorrect routing number, please try again.");
return checkRoutingNumber();
}
}
public boolean checkPIN() {
Scanner keyboard = new Scanner(System.in);
// checkPin();
System.out.print("Please enter your 4 digit PIN for confirmation: ");
int PIN = keyboard.nextInt(); // user's input
if (PIN == userPIN) {
return true;
} else {
System.out.println("\nIncorrect PIN, please try again.");
return checkPIN();
}
}
public boolean checkDigitalSignature() {
Scanner keyboard = new Scanner(System.in);
System.out.println("Sign below.\n");
String userInput = keyboard.next(); // user's input word
if (userInput.equals(userName)) {
return true;
} else {
System.out.println("Incorrect signature, please sign again.");
return checkDigitalSignature();
}
}
public String checkIRS() {
return "Under the Bank Secrecy Act, you are required to file an IRS form for exceeding the limit";
}
public void withdrawDollah() { //happens at bank or atm
// do we need to specify which type of account we are withdrawing from?
System.out.println("\nYou are now in the withdraw menu.");
checkDebitCardNum();
Scanner keyboard = new Scanner(System.in);
System.out.println("How much would you like to withdraw? ");
Double userInput = keyboard.nextDouble(); // user's input word
Double amount = userInput;
checkPIN();
if (amount > 10000) {
Scanner keyboard2 = new Scanner(System.in);
System.out.println("You are withdrawing a large amount of money. Are you sure you want to continue? (Y/N)");
String userInput2 = keyboard2.next(); // user's input word
if (userInput2.equalsIgnoreCase("y")) {
System.out.println("You are good to continue.");
if (amount < balance) {
checkDigitalSignature();
balance = balance - amount;
//totalSpent = totalSpent + amount;
System.out.println("Transaction completed. Withdrew $" + amount);
System.out.println("Your new balance is $" + balance);
} else {
System.out.println("Not enough money, please try again.");
withdrawDollah();
}
} else {
System.out.println("Transaction cancelled.");
}
}
}
public void spendDollah() {
// do we need to specify which type of account we are withdrawing from?
System.out.println("\nYou are now in the spending menu.");
checkDebitCardNum();
Scanner keyboard = new Scanner(System.in);
System.out.println("How much would you like to spend? ");
Double userInput = keyboard.nextDouble(); // user's input word
Double amount = userInput;
checkPIN();
if (amount > 10000) {
Scanner keyboard2 = new Scanner(System.in);
System.out.println("You are spending a large amount of money. Are you sure you want to continue? (Y/N)");
String userInput2 = keyboard2.next(); // user's input word
if (userInput2.equalsIgnoreCase("y")) {
System.out.println("You are good to continue.");
if (amount < balance) {
checkDigitalSignature();
balance = balance - amount;
totalSpent = totalSpent + amount;
System.out.println("Transaction completed. Spent $" + amount);
System.out.println("Your new balance is $" + balance);
} else {
System.out.println("Not enough money, please try again.");
spendDollah();
}
} else {
System.out.println("Transaction cancelled.");
}
}
}
public void depositDollah() {
System.out.println("\nYou are now in the deposit menu.");
Scanner keyboard = new Scanner(System.in);
System.out.println("How much would you like to deposit? ");
Double userInput = keyboard.nextDouble(); // user's input word
Double amount = userInput;
checkPIN(); // secondary security measure
if (amount >= 10000) {
System.out.println(checkIRS());
}
balance = balance + amount;
System.out.println("Transaction completed. Deposited $" + amount);
System.out.println("Your new balance is $" + balance);
}
// get method to get the total spent
public double getTotalSpent() {
return totalSpent;
}
public void setBalance(double b) {
abc.getCheckingAccount().setBalance(b);
balance = b;
}
}
class Credit extends Debit {
private double balance;
//private int RoutingNumber;
private double totalSpent = 0.0;
private int userPIN;
private double ccNUM;
private int CVV;
private double creditlimit;
private String userName;
private static user abc;
Credit() {
balance = 0.00;
//RoutingNumber = 420691234;
ccNUM = 1111123443216969.0;
CVV = 420;
creditlimit = 20000;
}
Credit(double bal, int PIN, String name, double num2, int numcvv, double limit) {
balance = bal;
//RoutingNumber = num;
userPIN = PIN;
userName = name;
ccNUM = num2;
numcvv = CVV;
creditlimit = limit;
}
Credit(double bal, int PIN, String name, double num2, int numcvv, double limit, user Person) {
balance = bal;
//RoutingNumber = num;
userPIN = PIN;
userName = name;
ccNUM = num2;
numcvv = CVV;
creditlimit = limit;
abc = Person;
}
public double getCCNum() {
return ccNUM;
}
public boolean checkCreditCardNum() { // checks credit card number AND cvv together
Scanner keyboard = new Scanner(System.in);
System.out.print("Please enter your credit card number for confirmation: ");
double userInput = keyboard.nextDouble();
if (userInput == ccNUM) {
checkCVV();
return true;
} else {
System.out.println("\nIncorrect credit card number, please try again.");
return checkDebitCardNum();
}
}
public void setUser(user person) {
abc = person;
}
public boolean checkLimit() {
if (getTotalSpent() > creditlimit) {
System.out.println("You are over your credit limit.");
return false;
} else {
return true;
}
}
public void spendDollah() {
// do we need to specify which type of account we are withdrawing from?
checkCreditCardNum();
Scanner keyboard = new Scanner(System.in);
System.out.println("How much are you spending? ");
Double userInput = keyboard.nextDouble(); // user's input word
Double amount = userInput;
checkPIN();
if (checkLimit()) {
if (amount > 10000) {
Scanner keyboard2 = new Scanner(System.in);
System.out.println("You are spending a large amount of money. Are you sure you want to continue? (Y/N)");
String userInput2 = keyboard2.next(); // user's input word
if (userInput2.equalsIgnoreCase("y")) {
System.out.println("You are good to continue.");
if (amount < balance) {
checkDigitalSignature();
balance = balance - amount;
totalSpent = totalSpent + amount;
System.out.println("Transaction completed. Spent $" + amount);
System.out.println("Your new balance is $" + balance);
} else {
System.out.println("Not enough money, please try again.");
spendDollah();
}
} else {
System.out.println("Transaction cancelled.");
}
}
}
}
public double getTotalDueEOM() {
//gets the total due at the EOM
return totalSpent;
}
public void setBalance(double b) {
abc.getCheckingAccount().setBalance(b);
balance = b;
}
}