Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desafio do banco digital Sergio #23

Open
Sergioprojgithub opened this issue Aug 5, 2024 · 1 comment
Open

Desafio do banco digital Sergio #23

Sergioprojgithub opened this issue Aug 5, 2024 · 1 comment

Comments

@Sergioprojgithub
Copy link

Sergioprojgithub commented Aug 5, 2024

Criei o arquivo no Eclipse do desafio banco digital, segue no comment os códigos!

@Sergioprojgithub
Copy link
Author

package Banco;

import java.util.List;

public class Banco {

private String nome;
private List<Conta> contas;

public String getNome() {
	return nome;
}

public void setNome(String nome) {
	this.nome = nome;
}

public List<Conta> getContas() {
	return contas;
}

public void setContas(List<Conta> contas) {
	this.contas = contas;
}

}
package Banco;

public class Cliente {

private String nome;

public String getNome() {
	return nome;
}

public void setNome(String nome) {
	this.nome = nome;
}

}

package Banco;

public abstract class Conta implements IConta {

private static final int AGENCIA_PADRAO = 1;
private static int SEQUENCIAL = 1;

protected int agencia;
protected int numero;
protected double saldo;
protected Cliente cliente;

public Conta(Cliente cliente) {
	this.agencia = Conta.AGENCIA_PADRAO;
	this.numero = SEQUENCIAL++;
	this.cliente = cliente;
}

@Override
public void sacar(double valor) {
	saldo -= valor;
}

@Override
public void depositar(double valor) {
	saldo += valor;
}

@Override
public void transferir(double valor, IConta contaDestino) {
	this.sacar(valor);
	contaDestino.depositar(valor);
}

public int getAgencia() {
	return agencia;
}

public int getNumero() {
	return numero;
}

public double getSaldo() {
	return saldo;
}

protected void imprimirInfosComuns() {
	System.out.println(String.format("Titular: %s", this.cliente.getNome()));
	System.out.println(String.format("Agencia: %d", this.agencia));
	System.out.println(String.format("Numero: %d", this.numero));
	System.out.println(String.format("Saldo: %.2f", this.saldo));
}

public void imprimirExtrato() {
	// TODO Auto-generated method stub
	
}

}
package Banco;

public class ContaCorrente extends Conta {

public ContaCorrente(Cliente cliente) {
	super(cliente);
}

@Override
public void imprimirExtrato() {
	System.out.println("=== Extrato Conta Corrente ===");
	super.imprimirInfosComuns();
}

}
package Banco;

public interface IConta {

void sacar(double valor);

void depositar(double valor);

void transferir(double valor, IConta contaDestino);

void imprimirExtrato();

}
package Banco;

public class ContaPoupanca extends Conta {

public ContaPoupanca(Cliente cliente) {
	super(cliente);
}

@Override
public void imprimirExtrato() {
	System.out.println("=== Extrato Conta Poupança ===");
	super.imprimirInfosComuns();
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant