diff --git a/.classpath b/.classpath deleted file mode 100644 index ac9ce57..0000000 --- a/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/.project b/.project deleted file mode 100644 index 194253a..0000000 --- a/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - refactoring - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000..f762d69 Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/module-info.java b/src/module-info.java deleted file mode 100644 index da5547f..0000000 --- a/src/module-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * - */ -/** - * @author rodrigo - * - */ -module refactoring { -} \ No newline at end of file diff --git a/src/primeiroRefactoring/Endereco.java b/src/primeiroRefactoring/Endereco.java new file mode 100644 index 0000000..f0cb87f --- /dev/null +++ b/src/primeiroRefactoring/Endereco.java @@ -0,0 +1,29 @@ +package primeiroRefactoring; + +import java.util.Date; + +public class Endereco { + + private String logradouro; + private String complemento; + private String 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; + } +} diff --git a/src/primeiroRefactoring/Pessoa.java b/src/primeiroRefactoring/Pessoa.java index b83ad11..d2e90f6 100644 --- a/src/primeiroRefactoring/Pessoa.java +++ b/src/primeiroRefactoring/Pessoa.java @@ -10,12 +10,10 @@ 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; @@ -23,9 +21,8 @@ public Pessoa(String nome, String cpf, String registroGeral, Date dataNascimento 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; @@ -63,22 +60,10 @@ 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 Endereco getEndereco() { + return endereco; } - public void setCep(String cep) { - this.cep = cep; + public void setEndereco(Endereco endereco) { + this.endereco = endereco; } } diff --git a/src/segundoRefactoring/Quicksort.java b/src/segundoRefactoring/Quicksort.java index e127d4c..b7a0aab 100644 --- a/src/segundoRefactoring/Quicksort.java +++ b/src/segundoRefactoring/Quicksort.java @@ -1,47 +1,55 @@ -package segundoRefactoring; - -import java.io.IOException; - -public class Quicksort { - - public static void main(String[] args) throws IOException { - int quantidade = 10000; - int[] vetor = new int[quantidade]; - - System.out.println("Vetor desordenado: "); - 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: "); - 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; - quickSort(vetor, inicio, posicaoPivo - 1); - quickSort(vetor, posicaoPivo + 1, fim); - } - } -} +package segundoRefactoring; + +import java.io.IOException; + +public class Quicksort { + + public static void main(String[] args) throws IOException { + int quantidade = 10000; + int[] vetor = new int[quantidade]; + + textMsg("Vetor desordenado: "); + for (int i = 0; i < vetor.length; i++) { + vetor[i] = (int) (Math.random() * quantidade); + System.out.print(i + " "); + } + quickSort(vetor, 0, vetor.length - 1); + textMsg("\nVetor ordenado: "); + for (int i : vetor) { + System.out.print(i + " "); + } + } + + private void textMsg(String msg){ + System.out.println(msg); + } + + private static void quickSort(int[] vetor, int inicio, int fim) { + if (inicio < fim) { + + int posicaoPivo = quebraLista(vetor, inicio, fim); + quickSort(vetor, inicio, posicaoPivo - 1); + quickSort(vetor, posicaoPivo + 1, fim); + } + } + + private static int quebraLista(int[] vetor, int inicio, 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; + } +} \ No newline at end of file diff --git a/src/terceiroRefactoring/Discente.java b/src/terceiroRefactoring/Discente.java index 9c68bec..161a575 100644 --- a/src/terceiroRefactoring/Discente.java +++ b/src/terceiroRefactoring/Discente.java @@ -1,51 +1,82 @@ -package terceiroRefactoring; - -import java.util.Date; - -public class Discente { - - private String[] disciplinasCursadas; - private Date dataIngresso; - private int numeroPeriodosCursados; - private String emailPessoal; - - public Discente(String[] disciplinasCursadas, Date dataIngresso, int numeroPeriodosCursados, String emailPessoal) { - super(); - this.disciplinasCursadas = disciplinasCursadas; - this.dataIngresso = dataIngresso; - this.numeroPeriodosCursados = numeroPeriodosCursados; - this.emailPessoal = emailPessoal; - } - - public String[] getDisciplinasCursadas() { - return disciplinasCursadas; - } - - public void setDisciplinasCursadas(String[] disciplinasCursadas) { - this.disciplinasCursadas = disciplinasCursadas; - } - - public Date getDataIngresso() { - return dataIngresso; - } - - public void setDataIngresso(Date dataIngresso) { - this.dataIngresso = dataIngresso; - } - - public int getNumeroPeriodosCursados() { - return numeroPeriodosCursados; - } - - public void setNumeroPeriodosCursados(int numeroPeriodosCursados) { - this.numeroPeriodosCursados = numeroPeriodosCursados; - } - - public String getEmailPessoal() { - return emailPessoal; - } - - public void setEmailPessoal(String emailPessoal) { - this.emailPessoal = emailPessoal; - } -} +package terceiroRefactoring; + +import java.util.Date; + +public class Discente extends Pessoa{ + + private String[] disciplinasCursadas; + private Date dataIngresso; + private int numeroPeriodosCursados; + private String emailPessoal; + private String matricula; + private double coeficienteRendimento; + private Pessoa pessoa; + + public Discente(String[] disciplinasCursadas, Date dataIngresso, int numeroPeriodosCursados, String emailPessoal, String matricula, + double coeficienteRendimento, Pessoa pessoa) { + super(); + this.disciplinasCursadas = disciplinasCursadas; + this.dataIngresso = dataIngresso; + this.numeroPeriodosCursados = numeroPeriodosCursados; + this.emailPessoal = emailPessoal; + this.matricula = matricula; + this.coeficienteRendimento = coeficienteRendimento; + this.pessoa = pessoa; + } + + public String[] getDisciplinasCursadas() { + return disciplinasCursadas; + } + + public void setDisciplinasCursadas(String[] disciplinasCursadas) { + this.disciplinasCursadas = disciplinasCursadas; + } + + public Date getDataIngresso() { + return dataIngresso; + } + + public void setDataIngresso(Date dataIngresso) { + this.dataIngresso = dataIngresso; + } + + public int getNumeroPeriodosCursados() { + return numeroPeriodosCursados; + } + + public void setNumeroPeriodosCursados(int numeroPeriodosCursados) { + this.numeroPeriodosCursados = numeroPeriodosCursados; + } + + public String getEmailPessoal() { + return emailPessoal; + } + + public void setEmailPessoal(String emailPessoal) { + this.emailPessoal = emailPessoal; + } + + public String getMatricula() { + return matricula; + } + + public void setMatricula(String matricula) { + this.matricula = matricula; + } + + public Pessoa getPessoa() { + return pessoa; + } + + public void setPessoa(Pessoa pessoa) { + this.pessoa = pessoa; + } + + public double getCoeficienteRendimento() { + return pessoa; + } + + public void setCoeficienteRendimento(double coeficienteRendimento) { + this.coeficienteRendimento = coeficienteRendimento; + } +} \ No newline at end of file diff --git a/src/terceiroRefactoring/Docente.java b/src/terceiroRefactoring/Docente.java index 1f17f04..d2bc737 100644 --- a/src/terceiroRefactoring/Docente.java +++ b/src/terceiroRefactoring/Docente.java @@ -1,51 +1,70 @@ -package terceiroRefactoring; - -import java.util.Date; - -public class Docente { - - private String[] disciplinasMinistradas; - private Date dataAdmissao; - private String emailInstitucional; - private double remuneracao; - - public Docente(String[] disciplinasMinistradas, Date dataAdmissao, String emailInstitucional, double remuneracao) { - super(); - this.disciplinasMinistradas = disciplinasMinistradas; - this.dataAdmissao = dataAdmissao; - this.emailInstitucional = emailInstitucional; - this.remuneracao = remuneracao; - } - - public String[] getDisciplinasMinistradas() { - return disciplinasMinistradas; - } - - public void setDisciplinasMinistradas(String[] disciplinasMinistradas) { - this.disciplinasMinistradas = disciplinasMinistradas; - } - - public Date getDataAdmissao() { - return dataAdmissao; - } - - 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; - } -} +package terceiroRefactoring; + +import java.util.Date; + +public class Docente extends Pessoa{ + + private String[] disciplinasMinistradas; + private Date dataAdmissao; + private String emailInstitucional; + private double remuneracao; + private String siape; + private Pessoa pessoa; + + public Docente(String[] disciplinasMinistradas, Date dataAdmissao, String emailInstitucional, double remuneracao, Pessoa pessoa) { + super(); + this.disciplinasMinistradas = disciplinasMinistradas; + this.dataAdmissao = dataAdmissao; + this.emailInstitucional = emailInstitucional; + this.remuneracao = remuneracao; + this.pessoa = pessoa; + } + + public String[] getDisciplinasMinistradas() { + return disciplinasMinistradas; + } + + public void setDisciplinasMinistradas(String[] disciplinasMinistradas) { + this.disciplinasMinistradas = disciplinasMinistradas; + } + + public Date getDataAdmissao() { + return dataAdmissao; + } + + 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; + } + + public Pessoa getPessoa() { + return pessoa; + } + + public void setPessoa(Pessoa pessoa) { + this.pessoa = pessoa;; + } +} \ No newline at end of file diff --git a/src/terceiroRefactoring/Pessoa.java b/src/terceiroRefactoring/Pessoa.java index 414afa9..930cc48 100644 --- a/src/terceiroRefactoring/Pessoa.java +++ b/src/terceiroRefactoring/Pessoa.java @@ -1,102 +1,83 @@ -package terceiroRefactoring; - -import java.util.Date; - -public class Pessoa { - - private String nomeCompleto; - private String cpf; - private String registroGeral; - private Date dataNascimento; - private String nomePai; - private String nomeMae; - private String siape; - private String matricula; - private double coeficienteRendimento; - - public Pessoa(String nomeCompleto, String cpf, String registroGeral, Date dataNascimento, String nomePai, - String nomeMae, String siape, String matricula, double coeficienteRendimento) { - 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; - } - - public String getNomeCompleto() { - return nomeCompleto; - } - - public void setNomeCompleto(String nomeCompleto) { - this.nomeCompleto = nomeCompleto; - } - - public String getCpf() { - return cpf; - } - - public void setCpf(String cpf) { - this.cpf = cpf; - } - - public String getRegistroGeral() { - return registroGeral; - } - - public void setRegistroGeral(String registroGeral) { - this.registroGeral = registroGeral; - } - - public Date getDataNascimento() { - return dataNascimento; - } - - public void setDataNascimento(Date dataNascimento) { - this.dataNascimento = dataNascimento; - } - - public String getNomePai() { - return nomePai; - } - - public void setNomePai(String nomePai) { - this.nomePai = nomePai; - } - - public String getNomeMae() { - return nomeMae; - } - - public void setNomeMae(String nomeMae) { - this.nomeMae = nomeMae; - } - - public String getSiape() { - return siape; - } - - 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; - } -} +package terceiroRefactoring; + +import java.util.Date; + +public class Pessoa { + + private String nomeCompleto; + private String cpf; + private String registroGeral; + private Date dataNascimento; + private String nomePai; + private String nomeMae; + + public Pessoa(String nomeCompleto, String cpf, String registroGeral, Date dataNascimento, String nomePai, + String nomeMae, String siape, String matricula, double coeficienteRendimento) { + 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; + } + + public String getNomeCompleto() { + return nomeCompleto; + } + + public void setNomeCompleto(String nomeCompleto) { + this.nomeCompleto = nomeCompleto; + } + + public String getCpf() { + return cpf; + } + + public void setCpf(String cpf) { + this.cpf = cpf; + } + + public String getRegistroGeral() { + return registroGeral; + } + + public void setRegistroGeral(String registroGeral) { + this.registroGeral = registroGeral; + } + + public Date getDataNascimento() { + return dataNascimento; + } + + public void setDataNascimento(Date dataNascimento) { + this.dataNascimento = dataNascimento; + } + + public String getNomePai() { + return nomePai; + } + + public void setNomePai(String nomePai) { + this.nomePai = nomePai; + } + + public String getNomeMae() { + return nomeMae; + } + + public void setNomeMae(String nomeMae) { + this.nomeMae = nomeMae; + } + + public double getCoeficienteRendimento() { + return coeficienteRendimento; + } + + public void setCoeficienteRendimento(double coeficienteRendimento) { + this.coeficienteRendimento = coeficienteRendimento; + } +} \ No newline at end of file