Created
June 15, 2022 01:11
-
-
Save mikansc/ca83c247313880e31c4f5b254abaddcc to your computer and use it in GitHub Desktop.
Aula DEVInHouse NDD - 14 06 2022 - POO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace OrietacaoObjeto; | |
class Conta | |
{ | |
private decimal Saldo; | |
public string Titular { get; set; } | |
public Conta(string nomeTitular, decimal saldoInicial) | |
{ | |
Titular = nomeTitular; | |
Saldo = saldoInicial; | |
} | |
public void Sacar(decimal valor) | |
{ | |
if (TemSaldo()) | |
{ | |
Saldo = Saldo - valor; | |
} | |
else | |
{ | |
System.Console.WriteLine("Não há saldo disponível"); | |
} | |
} | |
private bool TemSaldo() | |
{ | |
return Saldo > 0; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace OrietacaoObjeto; | |
class Pagamento | |
{ | |
public Guid Id { get; private set; } | |
public string Bandeira = string.Empty; | |
public DateTime DataPagamento { get; private set; } | |
private decimal ValorPago; | |
public decimal Valor | |
{ | |
get | |
{ | |
return ValorPago; | |
} | |
set | |
{ | |
ValorPago = value >= 0 ? value : 0; | |
} | |
} | |
public Pagamento(string bandeira) | |
{ | |
Id = Guid.NewGuid(); | |
Bandeira = bandeira; | |
} | |
public void Pagar(decimal valor) | |
{ | |
ValorPago = valor; | |
DataPagamento = DateTime.Now; | |
} | |
public void MostrarPagamento() | |
{ | |
Console.WriteLine("Pagamento realizado em {0:dd/MM/yyyy} as {0:HH:mm}.", DataPagamento); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment