-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterfaceTest.java
More file actions
69 lines (51 loc) · 1.2 KB
/
Copy pathInterfaceTest.java
File metadata and controls
69 lines (51 loc) · 1.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
public class InterfaceTest {
public static void main(String[] args) {
CurrentAcc ca = new CurrentAcc();
SavingsAcc sa = new SavingsAcc();
FundTransferServiceMethod.transfer(ca, sa, 50000);
System.out.println("balance : "+ca.balance);
System.out.println("balance : "+sa.balance);
}
}
interface Withdrawing1
{
public void withdraw(float amount);
}
interface Depositing1
{
void deposit(float amount);
}
class CurrentAcc implements Withdrawing1, Depositing1
{
float balance=80000;
public void withdraw(float amount)
{
balance = balance - amount;
}
public void deposit(float amount)
{
balance = balance + amount;
}
}
class SavingsAcc implements Withdrawing1, Depositing1
{
float balance=20000;
public void deposit(float amount)
{
balance = balance + amount;
}
public void withdraw(float amount)
{
balance = balance - amount;
}
}
class FundTransferServiceMethod
{
public static void transfer(Withdrawing1 c, Depositing1 s, float amount)
{
System.out.println("********Transfer Initiated********");
c.withdraw(amount);
s.deposit(amount);
System.out.println("********Transfer Done********");
}
}