-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
67 lines (49 loc) · 1.69 KB
/
Copy pathMain.java
File metadata and controls
67 lines (49 loc) · 1.69 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
public class Main {
public static void main(String[] args) {
BankAccount account =
new BankAccount(1000);
DepositTransaction deposit =
new DepositTransaction(
500,
"DEP001");
WithdrawalTransaction withdrawal =
new WithdrawalTransaction(
300,
"WTH001");
deposit.printTransactionDetails();
deposit.apply(account);
System.out.println(
"Balance: "
+ account.getBalance());
withdrawal.printTransactionDetails();
withdrawal.apply(account);
System.out.println(
"Balance: "
+ account.getBalance());
BaseTransaction bt1 =
(BaseTransaction) deposit;
BaseTransaction bt2 =
(BaseTransaction) withdrawal;
bt1.apply(account);
bt2.apply(account);
System.out.println(
"Balance after polymorphism test: "
+ account.getBalance());
boolean reversed =
withdrawal.reverse();
System.out.println(
"Withdrawal reversed: "
+ reversed);
System.out.println(
"Final Balance: "
+ account.getBalance());
WithdrawalTransaction wt =
new WithdrawalTransaction(
5000,
"WTH002");
wt.apply(account, true);
System.out.println(
"Amount Not Withdrawn: "
+ wt.getAmountNotWithdrawn());
}
}