-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBankingSystem.java
93 lines (82 loc) · 2.59 KB
/
BankingSystem.java
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
import java.util.Scanner;
public class BankingSystem {
boolean exit = false;
static boolean exitServices = false;
Scanner scan = new Scanner(System.in);
Account account;
public boolean isExit() {
return exit;
}
int startSession() {
System.out.println(
"\n1. Create an account\n"
+ "2. Log into account\n"
+ "0. Exit");
return scan.nextInt();
}
void getTask(int option) {
switch (option) {
case 1:
account = new Account();
break;
case 2:
logIn();
break;
case 0:
System.out.println("\nBye!");
exit = true;
break;
default:
break;
}
}
void logIn() {
System.out.println("Enter your card number:");
String cardNumber = scan.next();
System.out.println("Enter your PIN:");
String pin = scan.next();
account = new Account(cardNumber, pin);
if (account.authentication(pin, cardNumber)) {
System.out.println("You have successfully logged in!");
while (!exitServices) {
offerServices(cardNumber);
}
} else {
System.out.println("Wrong card number or PIN!");
}
}
void offerServices(String cardNumber) {
System.out.println("\n1. Balance\n"
+ "2. Add income\n"
+ "3. Do transfer\n"
+ "4. Close account\n"
+ "5. Log out\n"
+ "0. Exit");
switch (scan.nextInt()) {
case 1:
System.out.println("Balance: " + account.balanceChecker(cardNumber));
break;
case 2:
System.out.println("\nEnter income:");
account.addIncome(cardNumber, scan.nextInt());
System.out.println("Income was added!");
break;
case 3:
System.out.println("\nTransfer\nEnter card number:");
account.doTransfer(cardNumber,scan.next());
break;
case 4:
account.closeAccount(cardNumber);
break;
case 5:
System.out.println("You have successfully logged out!");
exitServices = true;
break;
case 0:
System.out.println("Bye!");
exitServices = true;
exit = true;
break;
}
}
}