-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses.py
More file actions
106 lines (56 loc) · 1.84 KB
/
classes.py
File metadata and controls
106 lines (56 loc) · 1.84 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#CLASES
class Person:
especie= 'Humano'
__pin_bancario=''
def __init__ (self,name,age):
self.name= name
self.age= age
def saludo(self):
return F'Hola Soy {self.name} !'
def guardar_pin(cls,pin):
cls.__pin_bancario= pin
return 'Pin Guardado con exito!'
def get_pinBancario(cls):
return cls.__pin_bancario
class Empleado(Person):
def __init__(self, name, age,puesto,company):
super().__init__(name, age)
self.puesto= puesto
self.company= company
persona1= Person('Juan',23)
#print(persona1.name)
#print(persona1.saludo())
persona1.guardar_pin('Abc123')
#print(persona1.get_pinBancario())
persona2= Empleado('Tito',22, 'dev','tenerello')
print(persona2.name)
print(persona2.age)
print(persona2.puesto)
persona2.guardar_pin('MiPIN2')
pin=persona2.get_pinBancario()
print(pin)
class BankAccount:
interest_rate=0.04
def __init__(self, holder,balance):
self.holder=holder
self.balance=balance
@classmethod
def change_interest_rate(cls,new_rate):
cls.interest_rate=new_rate
@staticmethod
def validate_amount(amount):
return amount>0
def withdraw (self, amount):
if(self.validate_amount(amount)):
if( self.balance>=amount):
self.balance -= amount
else:
print('No se puede retirar ese Monto es superior al Saldo')
else:
print('Ingrese un monto valido mayor a 0')
javier_account=BankAccount('javier',1000)
print(javier_account.holder)
print(javier_account.balance)
javier_account.withdraw(250)
print(javier_account.balance)
print(javier_account.withdraw(850))