You've already forked Curso-lenguaje-python
Restructure content and add notes from HolaMundo
Signed-off-by: Manuel Vergara <manuel@vergaracarmona.es>
This commit is contained in:
BIN
python-total/doc_curso/07_cuenta_bancaria/063Clases.pdf
Normal file
BIN
python-total/doc_curso/07_cuenta_bancaria/063Clases.pdf
Normal file
Binary file not shown.
BIN
python-total/doc_curso/07_cuenta_bancaria/064Atributos.pdf
Normal file
BIN
python-total/doc_curso/07_cuenta_bancaria/064Atributos.pdf
Normal file
Binary file not shown.
BIN
python-total/doc_curso/07_cuenta_bancaria/065Métodos.pdf
Normal file
BIN
python-total/doc_curso/07_cuenta_bancaria/065Métodos.pdf
Normal file
Binary file not shown.
Binary file not shown.
BIN
python-total/doc_curso/07_cuenta_bancaria/067Herencia.pdf
Normal file
BIN
python-total/doc_curso/07_cuenta_bancaria/067Herencia.pdf
Normal file
Binary file not shown.
Binary file not shown.
BIN
python-total/doc_curso/07_cuenta_bancaria/069Polimorfismo.pdf
Normal file
BIN
python-total/doc_curso/07_cuenta_bancaria/069Polimorfismo.pdf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,57 @@
|
||||
class Persona:
|
||||
|
||||
def __init__(self, nombre, apellido):
|
||||
self.nombre = nombre
|
||||
self.apellido = apellido
|
||||
|
||||
|
||||
class Cliente(Persona):
|
||||
def __init__(self, nombre, apellido, numero_cuenta, balance = 0):
|
||||
super().__init__(nombre, apellido)
|
||||
self.numero_cuenta = numero_cuenta
|
||||
self.balance = balance
|
||||
|
||||
def __str__(self):
|
||||
return f"Cliente: {self.nombre} {self.apellido}\nBalance de cuenta {self.numero_cuenta}: ${self.balance}"
|
||||
|
||||
def depositar(self, monto_deposito):
|
||||
self.balance += monto_deposito
|
||||
print("Deposito aceptado")
|
||||
|
||||
def retirar(self, monto_retiro):
|
||||
if self.balance >= monto_retiro:
|
||||
self.balance -= monto_retiro
|
||||
print("Retiro realizado")
|
||||
else:
|
||||
print("Fondos insuficientes")
|
||||
|
||||
|
||||
def crear_cliente():
|
||||
nombre_cl = input("Ingrese su nombre: ")
|
||||
apellido_cl = input("Ingrese su apellido: ")
|
||||
numero_cuenta = input("Ingrese su numero de cuenta: ")
|
||||
cliente = Cliente(nombre_cl, apellido_cl, numero_cuenta)
|
||||
return cliente
|
||||
|
||||
|
||||
def inicio():
|
||||
mi_cliente = crear_cliente()
|
||||
print(mi_cliente)
|
||||
opcion = 0
|
||||
|
||||
while opcion != 'S':
|
||||
print('Elije: Depositar (D), Retirar (R), o Salir (S)')
|
||||
opcion = input()
|
||||
|
||||
if opcion == 'D':
|
||||
monto_dep = int(input("Monto a depositar: "))
|
||||
mi_cliente.depositar(monto_dep)
|
||||
elif opcion == 'R':
|
||||
monto_ret = int(input("Monto a retirar: "))
|
||||
mi_cliente.retirar(monto_ret)
|
||||
print(mi_cliente)
|
||||
|
||||
print("Gracias por operar en Banco Python")
|
||||
|
||||
|
||||
inicio()
|
||||
Reference in New Issue
Block a user