-
Notifications
You must be signed in to change notification settings - Fork 0
/
Conta.cs
59 lines (51 loc) · 1.33 KB
/
Conta.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaixaEletronico
{
public abstract class Conta
{
public int Numero { get; set; }
public Cliente Titular { get; set; }
public double Saldo { get; protected set; }
public virtual void Deposita(double valor)
{
if (valor > 0)
{
this.Saldo += valor;
}
}
public virtual void Saca(double valor)
{
if (valor < 0.0)
{
throw new ArgumentException();
}
if (valor > this.Saldo)
{
throw new SaldoInsuficienteExcepition();
}
else
{
this.Saldo -= valor;
}
}
public void Transfere(double valor, Conta destino)
{
this.Saca(valor);
destino.Deposita(valor);
}
public double CalculaRendimentoAnual()
{
double saldoNaqueleMes = this.Saldo;
for (int i = 0; i < 12; i++)
{
saldoNaqueleMes = saldoNaqueleMes * 1.007;
}
double rendimento = saldoNaqueleMes - this.Saldo;
return rendimento;
}
}
}