-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathISA.java
More file actions
108 lines (100 loc) · 2.57 KB
/
ISA.java
File metadata and controls
108 lines (100 loc) · 2.57 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
//class Account{
abstract class Account{
int id;
final String branch = "Noida";
String name;
void deposit() {
System.out.println("Account Deposit");
}
void withDraw() {
System.out.println("Account WithDraw");
}
final void checkBalance() {
System.out.println("Account Check Balance");
}
//abstract void roi();
void roi() {
System.out.println("Generic ROI By Account");
}
}
final class SavingAccount extends Account{
@Override
void roi() {
System.out.println("Low Interest Rec From Bank");
}
void limitedTransInADay(){
System.out.println("Trans Limit is 5");
}
}
class CurrentAccount extends Account{
@Override
void roi() {
System.out.println("U need pay to the Bank");
}
void odLimit(){
System.out.println("OD Limit in Current Account");
}
}
class FixedDepositAccount extends Account{
@Override
void roi() {
System.out.println("High ROI pay by Bank");
}
void lockingPeriod(){
System.out.println("Amount is Locked for Sometime");
}
}
class Caller{
static void callMe(Account account) {
account.withDraw();
account.deposit();
account.roi();
System.out.println("**********************");
if(account instanceof SavingAccount) {
SavingAccount sa = (SavingAccount) account ; // Downcasting
sa.limitedTransInADay();
}
else
if(account instanceof FixedDepositAccount) {
FixedDepositAccount fa = (FixedDepositAccount) account ; // Downcasting
fa.lockingPeriod();
}
else
if(account instanceof CurrentAccount) {
((CurrentAccount) account).odLimit();
}
}
}
public class ISA {
public static void main(String[] args) {
//Caller.callMe(new Account());
final int X = 10;
final SavingAccount sa = new SavingAccount();
Caller.callMe(new SavingAccount());
Caller.callMe(new CurrentAccount());
Caller.callMe(new FixedDepositAccount());
// Account account = new FixedDepositAccount();
// account.withDraw();
// account.deposit();
// account.roi();
//account.limitedTransInADay();
// TODO Auto-generated method stub
/*SavingAccount savingAccount = new SavingAccount();
savingAccount.checkBalance();
savingAccount.withDraw();
savingAccount.roi();
savingAccount.limitedTransInADay();
System.out.println("**********************************");
CurrentAccount currentAccount = new CurrentAccount();
currentAccount.checkBalance();
currentAccount.withDraw();
currentAccount.roi();
currentAccount.odLimit();
System.out.println("**********************************");
FixedDepositAccount fd = new FixedDepositAccount();
fd.checkBalance();
fd.withDraw();
fd.roi();
fd.lockingPeriod();*/
}
}