-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBank account "__init__ & get methods
57 lines (44 loc) · 3.28 KB
/
Bank account "__init__ & get methods
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
class BankAccount: # Class Name
# This First Method is to define the Client Name.
def __init__(self, client_name): # Create initial method using __init__('self' refers to Class, 'client_name' is the purpose of this class):
self.name = client_name # 'self.name' self refers to the class. our objectif is the name
# This Method is to Get the Client Name.
def get_client_name(self): # Create another Method to get client name from the previous Method (self) refers to Class
return self.name # return function
################################################################################################################################################
this_account = BankAccount("Chalouli Toufik") # new instance = Class("give it a name")
print("This Account is Owned To :", this_account.get_client_name()) #print instance.get method
################################################################################################################################################
class BAnKaccount:
def __init__(self, client_balance):
self.balance = client_balance
def get_client_balance(self):
return self.balance
client_balance = BAnKaccount("20000.00")
print("This Client Balance is = ", client_balance.get_client_balance())
################################################################################################################################################
class AccountNumber:
def __init__(self, client_number):
self.number = client_number
def get_client_number(self):
return self.number
Client_Number = AccountNumber ("0796643919")
print("This is The Client Account number : ",Client_Number.get_client_number())
########################################################################################################################################
class BankAccount: # In this Class we declare all data of the client using __init__ methode
def __init__(self):
self.name = ("chalouli toufik".upper()) # Declare Client name.
self.balance = ("350000.00 DA") # Declare Client Balance.
self.number = ("0796643919") # Declare Client Number.
########################################################################################################################################
def get_client_name(self): # Function to get client name from __init__ function
return self.name # Get value from self.name
def get_client_balance(self): # Function to get client balance from __init__ function
return self.balance # Get value from self.balance
def get_client_number(self): # Function to get client number from __init__ function
return self.number # Get value from self.number
########################################################################################################################################
this_account = BankAccount() # Instance = Class name
print("This Account is Owned To :", this_account.get_client_name())
print("This Account Balance :", this_account.get_client_balance())
print("This Account Owner Number :", this_account.get_client_number())