-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathISADemo.java
More file actions
92 lines (79 loc) · 1.85 KB
/
ISADemo.java
File metadata and controls
92 lines (79 loc) · 1.85 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
class Account
{
double balance=10000;
int accountNo;
void checkBalance(){
System.out.println("balance is "+balance);
}
void roi(){
System.out.println("COMMON ROI....");
}
void withDraw(){
System.out.println("Common WithDraw..");
}
void deposit(){
System.out.println("Account Class Deposit...");
}
}
class SavingAccount extends Account
{
@Override
void roi(){
super.roi();
System.out.println("Saving AC ROI 4% Call");
}
// Annontation
@Override
void withDraw(){
System.out.println("Saving Account Limit for withdraw...");
}
}
class CurrentAccount extends Account{
void odLimit(){
System.out.println("CA OD Limit...");
}
@Override
void roi(){
System.out.println("Current AC 6% ROI Call");
}
}
class CallAccount{
//Man man = new NormalMan();
//Man man = new SuperMan();
//Account account = new SavingAccount();
public void doCall(Account account){
account.checkBalance();
account.deposit();
account.withDraw();
account.roi();
if(account instanceof CurrentAccount){
CurrentAccount ca = (CurrentAccount) account; // Downcasting
ca.odLimit();
}
//account.odLimit();
System.out.println("******************************");
}
}
public class ISADemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
CallAccount callAccount = new CallAccount();
callAccount.doCall(new SavingAccount());
callAccount.doCall(new CurrentAccount());
//Account account = new SavingAccount(); //Upcasting
//callAccount.doCall(account);
//SavingAccount sa = new SavingAccount();
//int a = 1000;
// account.checkBalance();
// account.deposit();
// account.withDraw();
// account.roi();
//System.out.println("**********************");
//account = new CurrentAccount(); //Upcasting
// account.checkBalance();
// account.deposit();
// account.withDraw();
// account.roi();
//ca.odLimit();
}
}