import java.applet.Applet;
import java.awt.*;
import java.util.Date;
public class BancoApplet extends Applet {
Label nomeBancoLabel;
Label mensagem;
String msg1 = "Faz mais por Voce";
Button clientesButton;
Button contasButton;
Button credite;
Button debite;
JanelaClientes janelaClientes;
JanelaContas janelaContas;
JanelaTransacao janelaTransacao;
Banco banco;
public void init() {
setLayout(new FlowLayout());
String nomeBanco = getParameter("nomeBanco");
banco = new Banco(nomeBanco , 100, 100);
nomeBancoLabel = new Label(nomeBanco, Label.CENTER);
nomeBancoLabel.setFont(new Font("Helvetica", Font.BOLD, 20));
add(nomeBancoLabel);
mensagem = new Label(msg1);
mensagem.setFont(new Font("Helvetica", Font.PLAIN, 16));
add(mensagem);
clientesButton = new Button("Atualiza Clientes");
add(clientesButton);
contasButton = new Button("Atualiza Contas");
add(contasButton);
debite = new Button("Lanca Debito");
add(debite);
credite = new Button("Lanca Credito");
add(credite);
janelaClientes = new JanelaClientes(this);
janelaContas = new JanelaContas(this);
janelaTransacao = new JanelaTransacao(this);
}
public boolean handleEvent(Event evt) {
if (evt.id == Event.ACTION_EVENT) {
if (evt.target == clientesButton) {
janelaClientes.pack();
janelaClientes.show();
} else if (evt.target == contasButton) {
janelaContas.pack();
janelaContas.show();
} else if (evt.target == credite) {
janelaTransacao.credite();
} else if (evt.target == debite) {
janelaTransacao.debite();
}
}
return super.handleEvent(evt);
}
public void adicionaCliente(String nome, String cpf) {
banco.adicionaCliente(new Cliente(nome,
(new Integer(cpf).intValue()),
10));
}
public void removeCliente(Cliente cliente) {
banco.removeCliente(cliente);
}
public void limpaClientes() {
banco.limpaClientes();
}
public Cliente cliente(int index) {
return banco.clientes[index];
}
public int qtdClientes() {
return banco.qtdClientes;
}
public Cliente[] clientes() {
return banco.clientes;
}
public void adicionaConta(String numero, String saldo) {
Cliente cliente = janelaClientes.clienteSelecionado();
banco.adicionaConta(new ContaBancaria(
(new Integer(numero).intValue()),
(new Integer(saldo).intValue()),
cliente,
100));
}
public void removeConta(ContaBancaria conta) {
banco.removeConta(conta);
}
public void limpaContas() {
banco.limpaContas();
}
public void atualizaListaContas() {
janelaContas.atualizaListaContas();
}
public ContaBancaria conta(int index) {
return banco.contas[index];
}
public int qtdContas() {
return banco.qtdContas;
}
public ContaBancaria[] contas() {
return banco.contas;
}
public void adicionaTransacaoDebito(Date data, int valor) {
ContaBancaria conta = janelaContas.contaSelecionada();
banco.adicionaTransacaoDebito(conta, data, valor);
janelaContas.atualizaListaContas();
}
public void adicionaTransacaoCredito(Date data, int valor) {
ContaBancaria conta = janelaContas.contaSelecionada();
banco.adicionaTransacaoCredito(conta, data, valor);
janelaContas.atualizaListaContas();
}
}