Skip to content

Commit

Permalink
Merge pull request #46 from Salgado2004/39-design
Browse files Browse the repository at this point in the history
39 design
  • Loading branch information
Salgado2004 authored Jun 13, 2024
2 parents 025e554 + 20f7ea3 commit 2320198
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/main/br/ufpr/controllers/Imagens.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public enum Imagens {
EYE_CLOSED("eye_closed.png"),
SEARCH("search.png"),
DELETE("delete.png"),
EDIT("edit.png"),
ADD("add.png"),
DEPOSITO("deposito.png"),
SAQUE("saque.png"),
REMUNERA("remunera.png"),
Expand Down
6 changes: 3 additions & 3 deletions src/main/br/ufpr/controllers/Sistema.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ public static void main(String[] args){
frame.setVisible(true);

Endereco endereco1 = new Endereco("Rua A", "Prado Velho", "250", "Curitiba");
Cliente c1 = new Cliente("Pedro", "Souza", endereco1, "09124024902", "129711280");
Cliente c1 = new Cliente("Pedro", "Souza", endereco1, "948.312.270-80", "129711280");
cadastrarCliente(c1);

Endereco endereco2 = new Endereco("Rua B", "Cajuru", "1134", "Curitiba");
Cliente c2 = new Cliente("Alisson", "Santos", endereco2, "11754317960", "119264210");
Cliente c2 = new Cliente("Alisson", "Santos", endereco2, "885.434.710-87", "119264210");
cadastrarCliente(c2);

Endereco endereco3 = new Endereco("Rua C", "Jardim Amélia", "65", "Pinhais");
Cliente c3 = new Cliente("Leonardo", "Salgado", endereco3, "10619416980", "129321481");
Cliente c3 = new Cliente("Leonardo", "Salgado", endereco3, "632.872.080-71", "129321481");
cadastrarCliente(c3);
}

Expand Down
79 changes: 77 additions & 2 deletions src/main/br/ufpr/models/Cliente.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,59 @@ public Cliente(String nome, String sobrenome, Endereco endereco, String cpf, Str
this.cpf = cpf;
}

// Os getters e setters para as variáveis de instância estão aqui.
public String getNome() {
return nome;
}

public void setNome(String nome) {
nome = nome.toUpperCase();

if (!validaNome(nome)) {
throw new IllegalArgumentException("Nome inválido");
}
this.nome = nome;
}

public String getSobrenome() {
return sobrenome;
}

public void setSobrenome(String sobrenome) {
sobrenome = sobrenome.toUpperCase();
if (!validaNome(sobrenome)) {
throw new IllegalArgumentException("Sobrenome inválido");
}
this.sobrenome = sobrenome;
}


public Endereco getEndereco() {
return endereco;
}

public void setEndereco(Endereco endereco) {
this.endereco = endereco;
}

public String getCpf() {
return cpf;
}

public String getRg() {
return rg;
}

public void setRg(String rg) {
this.rg = rg;
}

public Conta getConta() {
return conta;
}

public void setConta(Conta conta) {
this.conta = conta;
}

/**
* Este método valida o nome do cliente.
Expand All @@ -62,7 +114,30 @@ private boolean validaCpf(String cpf) {
int soma = 0, resto = 0;

if(cpf.matches("[0-9]{11}") && !cpf.matches("^(\\d)\\1{10}")){
// A lógica de validação do CPF está aqui.
for (int i = 0; i < 9; i++) {
soma += Integer.parseInt(cpf.substring(i, i + 1)) * (10 - i);
}
resto = 11 - (soma % 11);
if (resto == 10 || resto == 11) {
resto = 0;
}
if (resto != Integer.parseInt(cpf.substring(9, 10))) {
return false;
}

soma = 0;
for (int i = 0; i < 10; i++) {
soma += Integer.parseInt(cpf.substring(i, i + 1)) * (11 - i);
}
resto = 11 - (soma % 11);
if (resto == 10 || resto == 11) {
resto = 0;
}
if (resto != Integer.parseInt(cpf.substring(10, 11))) {
return false;
}

return true;
}
return false;
}
Expand Down
12 changes: 11 additions & 1 deletion src/main/br/ufpr/models/Conta.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,17 @@ public boolean saca(double valor) {
return false;
}

// Os getters para as variáveis de instância estão aqui.
public Cliente getDono() {
return this.dono;
}

public int getNumero() {
return this.numero;
}

public double getSaldo() {
return this.saldo;
}

/**
* Este é um método abstrato que deve ser implementado nas subclasses.
Expand Down
12 changes: 11 additions & 1 deletion src/main/br/ufpr/models/ContaCorrente.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@ public ContaCorrente(Cliente dono, double saldo, double limite) {
this.limite = limite;
}

// Os getters e setters para as variáveis de instância estão aqui.
public double getLimite() {
return this.limite;
}

public void setLimite(double limite) {
this.limite = limite;
}

public double getDepositoInicial() {
return this.depositoInicial;
}

/**
* Este método saca um valor da conta.
Expand Down
16 changes: 15 additions & 1 deletion src/main/br/ufpr/models/Endereco.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,21 @@ public Endereco(String logradouro, String bairro, String numeroS, String cidade)
this.cidade = cidade.toUpperCase();
}

// Os getters para as variáveis de instância estão aqui.
public String getLogradouro() {
return logradouro;
}

public String getBairro() {
return bairro;
}

public int getNumero() {
return numero;
}

public String getCidade() {
return cidade;
}

/**
* Este método privado verifica se o número é válido.
Expand Down
15 changes: 12 additions & 3 deletions src/main/br/ufpr/views/ManterCliente.form
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="main.br.ufpr.views.ManterCliente">
<grid id="27dc6" binding="frame" layout-manager="GridLayoutManager" row-count="7" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="frame" layout-manager="GridLayoutManager" row-count="8" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="8" left="8" bottom="8" right="8"/>
<constraints>
<xy x="20" y="20" width="758" height="400"/>
Expand Down Expand Up @@ -208,7 +208,7 @@
</component>
<scrollpane id="1215a" binding="scrollPanel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="4" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="4" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-14134075"/>
Expand Down Expand Up @@ -246,7 +246,7 @@
</component>
<component id="2b639" class="javax.swing.JButton" binding="voltarButton" default-binding="true">
<constraints>
<grid row="6" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
<grid row="7" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-11487489"/>
Expand All @@ -271,6 +271,15 @@
<text value="Excluir"/>
</properties>
</component>
<component id="c00b7" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<foreground color="-1967873"/>
<text value="Clientes cadastrados"/>
</properties>
</component>
</children>
</grid>
</form>
12 changes: 12 additions & 0 deletions src/main/br/ufpr/views/ManterCliente.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package main.br.ufpr.views;

import main.br.ufpr.controllers.Imagens;
import main.br.ufpr.controllers.Mensagens;
import main.br.ufpr.controllers.Sistema;
import main.br.ufpr.models.Cliente;
import main.br.ufpr.models.Endereco;
import main.br.ufpr.models.Tela;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
Expand All @@ -29,6 +31,7 @@ public class ManterCliente implements Tela {
private JButton inserirButton;
private JButton editarButton;
private JButton excluirButton;
private JScrollPane scrollPanel;
private ManterClienteTableModel tabelaModel = new ManterClienteTableModel(Sistema.getClientes());


Expand All @@ -39,6 +42,15 @@ public class ManterCliente implements Tela {
public ManterCliente() {
tabelaClientes.setModel(tabelaModel);
tabelaClientes.setColumnModel(tabelaClientes.getColumnModel());

excluirButton.setIcon(Imagens.DELETE.icon());
editarButton.setIcon(Imagens.EDIT.icon());
buscarButton.setIcon(Imagens.SEARCH.icon());
inserirButton.setIcon(Imagens.ADD.icon());

scrollPanel.getViewport().setBackground(new Color(5,28,59));
tabelaClientes.getTableHeader().setBackground(new Color(225,248,255));

voltarButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/br/ufpr/views/VincularCliente.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import main.br.ufpr.models.Tela;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Objects;
Expand Down Expand Up @@ -36,6 +37,7 @@ public class VincularCliente implements Tela {
private Cliente clienteSelecionado;
private ContaCorrente corrente;
private ContaInvestimento investimento;
private JScrollPane scrollPanel;
/**
* Construtor da classe VincularCliente.
* Inicializa os componentes da interface e define os listeners dos botões.
Expand All @@ -47,6 +49,8 @@ public VincularCliente() {
tabela.setModel(tabelaModel);
tabela.setColumnModel(tabela.getColumnModel());

scrollPanel.getViewport().setBackground(new Color(5,28,59));
tabela.getTableHeader().setBackground(new Color(225,248,255));

voltarButton.addActionListener(new ActionListener() {
@Override
Expand Down

0 comments on commit 2320198

Please sign in to comment.