-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconta.py
More file actions
43 lines (33 loc) · 1.19 KB
/
conta.py
File metadata and controls
43 lines (33 loc) · 1.19 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
#-*- coding: latin1 -*-
from errors import ValorInvalidoError
from errors import SaldoInsuficienteError
class Conta:
def __init__(self, numero):
self.numero = numero
self.saldo = 0.0
self.extrato=[]
def __str__(self):
return " Conta " + str(self.numero) + "\n" + " Saldo R$" + str(self.saldo)
def op_saldo(self) :
return self.saldo
def op_saque(self, valor) :
if (valor > self.saldo) :
raise SaldoInsuficienteError()
elif (valor <= 0):
raise ValorInvalidoError()
else :
self.saldo = self.saldo - valor
self.extrato.append("R$: "+str(valor)+" (Saque)");
def op_deposito(self, valor) :
if (valor <= 0):
raise ValorInvalidoError()
else :
self.saldo = self.saldo + valor
self.extrato.append("R$: "+str(valor)+" (Depósito)");
def get_extrato(self):
texto="Extrato – Conta: "+str(self.numero)+"\n----------------\n"
for x in range(len(self.extrato)):
texto+=self.extrato[x]+"\n"
texto+="----------------\n"
texto+="Saldo Atual: R$ "+str(self.saldo)
return texto