forked from akash-coded/C133-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractPracticeAvinash.java
86 lines (71 loc) · 2.33 KB
/
AbstractPracticeAvinash.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
import java.util.*;
abstract class BankAcc {
int Balance = 0;
final static String currencyType = "INR";
abstract void ShowAccBal();
abstract void withdrawMoney(int Debit);
abstract void depositMoney(int Credit);
String showCurrencyType() {
return currencyType;
}
}
class SBI extends BankAcc {
void ShowAccBal() {
System.out.println("Your current account balance in SBI is " + showCurrencyType() + " " + Balance);
}
void withdrawMoney(int Debit) {
if (Debit > Balance) {
System.out.println("You don't have enough money in your account to withdraw.");
} else {
Balance -= Debit;
System.out.println("Your account has been debited with amount " + Debit);
}
ShowAccBal();
}
void depositMoney(int Credit) {
Balance += Credit;
System.out.println("Your account has been credited with amount " + Credit);
ShowAccBal();
}
}
class PNB extends BankAcc {
int count = 0;
void ShowAccBal() {
System.out.println("Your current account balance in SBI is " + showCurrencyType() + " " + Balance);
}
void withdrawMoney(int Debit) {
if (Debit > Balance) {
System.out.println("You don't have enough money in your account to withdraw.");
} else {
Balance -= Debit;
System.out.println("Your account has been debited with amount " + Debit);
}
ShowAccBal();
}
void depositMoney(int Credit) {
Balance += Credit;
System.out.println("Your account has been credited with amount " + Credit);
ShowAccBal();
}
}
public class AbstractPracticeAvinash {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter your bank name : ");
String Bank = sc.nextLine();
sc.close();
if (Bank.equals("PNB")) {
PNB pnb = new PNB();
pnb.ShowAccBal();
pnb.depositMoney(20000);
pnb.withdrawMoney(15000);
} else if (Bank.equals("SBI")) {
SBI sbi = new SBI();
sbi.ShowAccBal();
sbi.depositMoney(20000);
sbi.withdrawMoney(15000);
} else {
System.out.println("The services for this bank is not available.");
}
}
}