-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcuentaJoven_electronica.py
More file actions
81 lines (68 loc) · 2.33 KB
/
Copy pathcuentaJoven_electronica.py
File metadata and controls
81 lines (68 loc) · 2.33 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
class Cuenta():
def __init__(self, titular, cantidad=0):
self.titular = titular
self.__cantidad = cantidad
def menu(self):
print('---MENU---')
print('1- Mostrar datos de la cuenta')
print('2- Ingresar cantidad')
print('3- Retirar cantidad')
print('4- Salir')
opcion = int(input('Seleccione una opción: '))
while True:
if opcion == 1:
self.mostrar()
elif opcion == 2:
self.ingresar()
elif opcion == 3:
self.retirar()
elif opcion == 4:
print('Ha cerrado sesión')
exit()
else:
print('ERROR - Opción no válida')
self.menu()
break
def mostrar(self):
print(f'Titular de la cuenta:{self.titular}\nCantidad en cuenta:{self.__cantidad}')
def ingresar(self):
monto = float(input('Ingrese el monto: '))
if monto > 0:
self.__cantidad += monto
else:
print('No válido')
def retirar(self):
monto = float(input('Ingrese el monto: '))
if monto > 0:
self.__cantidad -= monto
#CREO LA CUENTA JOVEN. LA CLASE
class CuentaJoven(Cuenta):
def __init__(self, titular, cantidad=0, bonificacion=0):
Cuenta.__init__(self, titular, cantidad=0)
self.__cantidad = cantidad
self.bonificacion = bonificacion
def ingresar(self):
monto = float(input('Ingrese el monto de la Cuenta Joven: '))
if monto > 0:
self.__cantidad += monto
else:
print('No válido')
def retirar(self):
monto = float(input('Ingrese el monto a retirar: '))
if monto > 0:
self.__cantidad -= monto
def esTitularValido(self):
edad = int(input('Ingrese edad: '))
if edad > 17 and edad < 26:
es_titular = True
else:
es_titular = False
return es_titular
def mostrar(self):
print('CUENTA JOVEN')
print(f'Titular de la cuenta:{self.titular}\nCantidad en cuenta:{self.__cantidad}\nBonificación:{self.bonificacion}%')
#cuenta = Cuenta('Alfredo')
cuenta_j = CuentaJoven('Ricardo', 1000, 50)
#cuenta.menu()
if cuenta_j.esTitularValido():
cuenta_j.menu()