-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
55 lines (37 loc) · 1.04 KB
/
main.py
File metadata and controls
55 lines (37 loc) · 1.04 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
from account import Account, Average, SavingsAccount
#create accounts
acc1 = Account("Ezz", "100", 54000)
acc2 = Account("Ali", "112", 35000)
sav1 = SavingsAccount("Mostafa", "287", 12000, 8) # interest_rate 8%
sav2 = SavingsAccount("Adham", "265", 23000, 5) # interest_rate 5%
#trying the main methods
acc1.deposit(10000)
acc2.withdraw(300)
sav1.deposit(450)
sav2.withdraw(1000)
sav1.add_interest()
sav2.add_interest()
print()
#trying Magic methods
print(acc1)
print(acc2)
print(sav1)
print(acc1 + acc2)
print(acc1 < acc2)
print(acc1["owner_name"])
print(acc2["balance"])
print()
#using Property
print(f"Account 1 balance: {acc1.show_balance}")
print(f"Savings 1 balance: {sav1.show_balance}")
print()
#using Average
avg_calc = Average()
avg_calc.add_account(acc1)
avg_calc.add_account(acc2)
avg_calc.add_account(sav1)
avg_calc.add_account(sav2)
avg_calc.average_balance()
print()
#trying class variables
print(f"Total accounts created: {Account.total_accounts}")