Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode
38 changes: 38 additions & 0 deletions src/primeiroRefactoring/Endereco.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package primeiroRefactoring;

public class Endereco {
private String logradouro;
private String complemento;
private String cep;

public Pessoa(String logradouro, String complemento, String cep) {
super();
this.logradouro = logradouro;
this.complemento = complemento;
this.cep = cep;
}

public String getLogradouro() {
return logradouro;
}

public void setLogradouro(String logradouro) {
this.logradouro = logradouro;
}

public String getComplemento() {
return complemento;
}

public void setComplemento(String complemento) {
this.complemento = complemento;
}

public String getCep() {
return cep;
}

public void setCep(String cep) {
this.cep = cep;
}
}
34 changes: 10 additions & 24 deletions src/primeiroRefactoring/Pessoa.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package primeiroRefactoring;

import java.util.Date;
import primeiroRefactoring.Endereco;

public class Pessoa {

Expand All @@ -10,22 +11,17 @@ public class Pessoa {
private Date dataNascimento;
private String nomePai;
private String nomeMae;
private String logradouro;
private String complemento;
private String cep;
private Endereco endereco;

public Pessoa(String nome, String cpf, String registroGeral, Date dataNascimento, String nomePai, String nomeMae,
String logradouro, String complemento, String cep) {
public Pessoa(String nome, String cpf, String registroGeral, Date dataNascimento, String nomePai, String nomeMae, Endereco endereco) {
super();
this.nome = nome;
this.cpf = cpf;
this.registroGeral = registroGeral;
this.dataNascimento = dataNascimento;
this.nomePai = nomePai;
this.nomeMae = nomeMae;
this.logradouro = logradouro;
this.complemento = complemento;
this.cep = cep;
this.endereco = endereco;
}
public String getNome() {
return nome;
Expand Down Expand Up @@ -63,22 +59,12 @@ public String getNomeMae() {
public void setNomeMae(String nomeMae) {
this.nomeMae = nomeMae;
}
public String getLogradouro() {
return logradouro;
}
public void setLogradouro(String logradouro) {
this.logradouro = logradouro;
}
public String getComplemento() {
return complemento;
}
public void setComplemento(String complemento) {
this.complemento = complemento;
}
public String getCep() {
return cep;

public getEndereco() {
return this.endereco;
}
public void setCep(String cep) {
this.cep = cep;

public setEndereco(Endereco endereco) {
this.endereco = endereco;
}
}
61 changes: 39 additions & 22 deletions src/segundoRefactoring/Quicksort.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,57 @@ public static void main(String[] args) throws IOException {
int quantidade = 10000;
int[] vetor = new int[quantidade];

System.out.println("Vetor desordenado: ");
vetor = preencherVetorAleatoriamente(vetor);

printVetor(vetor, "Vetor desordenado: ");

quickSort(vetor, 0, vetor.length - 1);

printVetor(vetor, "Vetor ordenado: ");
}

private static int[] preencherVetorAleatoriamente(vetor) {
for (int i = 0; i < vetor.length; i++) {
vetor[i] = (int) (Math.random() * quantidade);
System.out.print(i + " ");
}
quickSort(vetor, 0, vetor.length - 1);
System.out.println("\nVetor ordenado: ");

return vetor;
}

private static void printVetor(vetor, legenda) {
System.out.print(legenda);
for (int i : vetor) {
System.out.print(i + " ");
}
}

private static void quickSort(int[] vetor, int inicio, int fim) {
if (inicio < fim) {
int pivo = vetor[inicio];
int i = inicio + 1, f = fim;
while (i <= f) {
if (vetor[i] <= pivo)
i++;
else if (pivo < vetor[f])
f--;
else {
int troca = vetor[i];
vetor[i] = vetor[f];
vetor[f] = troca;
i++;
f--;
}
}
vetor[inicio] = vetor[f];
vetor[f] = pivo;
int posicaoPivo = f;
int posicaoPivo = particionarLista(vetor, inicio, fim);
quickSort(vetor, inicio, posicaoPivo - 1);
quickSort(vetor, posicaoPivo + 1, fim);
}
}

private static void particionarLista(int[] vetor, int incio, int fim) {
int pivo = vetor[inicio];
int i = inicio + 1, f = fim;
while (i <= f) {
if (vetor[i] <= pivo)
i++;
else if (pivo < vetor[f])
f--;
else {
int troca = vetor[i];
vetor[i] = vetor[f];
vetor[f] = troca;
i++;
f--;
}
}
vetor[inicio] = vetor[f];
vetor[f] = pivo;

return f;
}
}
28 changes: 19 additions & 9 deletions src/terceiroRefactoring/Discente.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@

import java.util.Date;

public class Discente {
public class Discente extends Pessoa {

private String[] disciplinasCursadas;
private Date dataIngresso;
private int numeroPeriodosCursados;
private String emailPessoal;
private String matricula;
private double coeficienteRendimento;

public Discente(String[] disciplinasCursadas, Date dataIngresso, int numeroPeriodosCursados, String emailPessoal) {
super();
public Discente(String[] disciplinasCursadas, Date dataIngresso, int numeroPeriodosCursados, String matricula, double coeficienteRendimento, String nomeCompleto, String cpf, String registroGeral, Date dataNascimento, String nomePai, String nomeMae, String email) {
super(nomeCompleto, cpf, registroGeral, dataNascimento, nomePai, nomeMae, email);
this.disciplinasCursadas = disciplinasCursadas;
this.dataIngresso = dataIngresso;
this.numeroPeriodosCursados = numeroPeriodosCursados;
this.emailPessoal = emailPessoal;
this.matricula = matricula;
this.coeficienteRendimento = coeficienteRendimento;
}

public String[] getDisciplinasCursadas() {
Expand All @@ -41,11 +43,19 @@ public void setNumeroPeriodosCursados(int numeroPeriodosCursados) {
this.numeroPeriodosCursados = numeroPeriodosCursados;
}

public String getEmailPessoal() {
return emailPessoal;
public String getMatricula() {
return matricula;
}

public void setEmailPessoal(String emailPessoal) {
this.emailPessoal = emailPessoal;
public void setMatricula(String matricula) {
this.matricula = matricula;
}

public double getCoeficienteRendimento() {
return coeficienteRendimento;
}

public void setCoeficienteRendimento(double coeficienteRendimento) {
this.coeficienteRendimento = coeficienteRendimento;
}
}
25 changes: 13 additions & 12 deletions src/terceiroRefactoring/Docente.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

import java.util.Date;

public class Docente {
public class Docente extends Pessoa {

private String[] disciplinasMinistradas;
private Date dataAdmissao;
private String emailInstitucional;
private double remuneracao;
private String siape;

public Docente(String[] disciplinasMinistradas, Date dataAdmissao, String emailInstitucional, double remuneracao) {
super();
public Docente(String[] disciplinasMinistradas, Date dataAdmissao, double remuneracao, String siape, String nomeCompleto, String cpf, String registroGeral, Date dataNascimento, String nomePai, String nomeMae, String email) {
super(nomeCompleto, cpf, registroGeral, dataNascimento, nomePai, nomeMae, email);
this.disciplinasMinistradas = disciplinasMinistradas;
this.dataAdmissao = dataAdmissao;
this.emailInstitucional = emailInstitucional;
this.remuneracao = remuneracao;
this.siape = siape;
}

public String[] getDisciplinasMinistradas() {
Expand All @@ -33,19 +34,19 @@ public void setDataAdmissao(Date dataAdmissao) {
this.dataAdmissao = dataAdmissao;
}

public String getEmailInstitucional() {
return emailInstitucional;
}

public void setEmailInstitucional(String emailInstitucional) {
this.emailInstitucional = emailInstitucional;
}

public double getRemuneracao() {
return remuneracao;
}

public void setRemuneracao(double remuneracao) {
this.remuneracao = remuneracao;
}

public String getSiape() {
return siape;
}

public void setSiape(String siape) {
this.siape = siape;
}
}
35 changes: 7 additions & 28 deletions src/terceiroRefactoring/Pessoa.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,17 @@ public class Pessoa {
private Date dataNascimento;
private String nomePai;
private String nomeMae;
private String siape;
private String matricula;
private double coeficienteRendimento;
private String email;

public Pessoa(String nomeCompleto, String cpf, String registroGeral, Date dataNascimento, String nomePai,
String nomeMae, String siape, String matricula, double coeficienteRendimento) {
public Pessoa(String nomeCompleto, String cpf, String registroGeral, Date dataNascimento, String nomePai, String nomeMae, String email) {
super();
this.nomeCompleto = nomeCompleto;
this.cpf = cpf;
this.registroGeral = registroGeral;
this.dataNascimento = dataNascimento;
this.nomePai = nomePai;
this.nomeMae = nomeMae;
this.siape = siape;
this.matricula = matricula;
this.coeficienteRendimento = coeficienteRendimento;
this.email = email;
}

public String getNomeCompleto() {
Expand Down Expand Up @@ -76,27 +71,11 @@ public void setNomeMae(String nomeMae) {
this.nomeMae = nomeMae;
}

public String getSiape() {
return siape;
public String getEmail() {
return this.email;
}

public void setSiape(String siape) {
this.siape = siape;
}

public String getMatricula() {
return matricula;
}

public void setMatricula(String matricula) {
this.matricula = matricula;
}

public double getCoeficienteRendimento() {
return coeficienteRendimento;
}

public void setCoeficienteRendimento(double coeficienteRendimento) {
this.coeficienteRendimento = coeficienteRendimento;
public void setEmail(String email) {
this.email = email;
}
}