|
| 1 | +package cursojava.classes; |
| 2 | + |
| 3 | +import java.util.ArrayList; |
| 4 | +import java.util.List; |
| 5 | + |
| 6 | +//Classe que representa o Aluno. |
| 7 | + |
| 8 | +public class Aluno { |
| 9 | + |
| 10 | + private String nome; |
| 11 | + private int idade; |
| 12 | + private String dataNascimento; |
| 13 | + private String registroGeral; |
| 14 | + private String numeroCpf; |
| 15 | + private String nomeMae; |
| 16 | + private String nomePai; |
| 17 | + private String dataMatricula; |
| 18 | + private String nomeEscola; |
| 19 | + private String serieMatriculado; |
| 20 | + |
| 21 | + |
| 22 | + private List<Disciplina> disciplinas = new ArrayList<Disciplina>(); |
| 23 | + private List<Bimestre> bimestres = new ArrayList<Bimestre>(); |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + public void setDisciplinas(List<Disciplina> disciplinas) { |
| 28 | + this.disciplinas = disciplinas; |
| 29 | + } |
| 30 | + |
| 31 | + public List<Disciplina> getDisciplinas() { |
| 32 | + return disciplinas; |
| 33 | + } |
| 34 | + |
| 35 | + |
| 36 | + public Aluno() { |
| 37 | + // TODO Auto-generated constructor stub |
| 38 | + } |
| 39 | + |
| 40 | + public Aluno(String nomeDefault, int idadeDefault) { |
| 41 | + // TODO Auto-generated constructor stub |
| 42 | + |
| 43 | + nome = nomeDefault; |
| 44 | + idade = idadeDefault; |
| 45 | + } |
| 46 | + |
| 47 | + public String getNome() { |
| 48 | + return nome; |
| 49 | + } |
| 50 | + |
| 51 | + public void setNome(String nome) { |
| 52 | + this.nome = nome; |
| 53 | + } |
| 54 | + |
| 55 | + public int getIdade() { |
| 56 | + return idade; |
| 57 | + } |
| 58 | + |
| 59 | + public void setIdade(int idade) { |
| 60 | + this.idade = idade; |
| 61 | + } |
| 62 | + |
| 63 | + public String getDataNascimento() { |
| 64 | + return dataNascimento; |
| 65 | + } |
| 66 | + |
| 67 | + public void setDataNascimento(String dataNascimento) { |
| 68 | + this.dataNascimento = dataNascimento; |
| 69 | + } |
| 70 | + |
| 71 | + public String getRegistroGeral() { |
| 72 | + return registroGeral; |
| 73 | + } |
| 74 | + |
| 75 | + public void setRegistroGeral(String registroGeral) { |
| 76 | + this.registroGeral = registroGeral; |
| 77 | + } |
| 78 | + |
| 79 | + public String getNumeroCpf() { |
| 80 | + return numeroCpf; |
| 81 | + } |
| 82 | + |
| 83 | + public void setNumeroCpf(String numeroCpf) { |
| 84 | + this.numeroCpf = numeroCpf; |
| 85 | + } |
| 86 | + |
| 87 | + public String getNomeMae() { |
| 88 | + return nomeMae; |
| 89 | + } |
| 90 | + |
| 91 | + public void setNomeMae(String nomeMae) { |
| 92 | + this.nomeMae = nomeMae; |
| 93 | + } |
| 94 | + |
| 95 | + public String getNomePai() { |
| 96 | + return nomePai; |
| 97 | + } |
| 98 | + |
| 99 | + public void setNomePai(String nomePai) { |
| 100 | + this.nomePai = nomePai; |
| 101 | + } |
| 102 | + |
| 103 | + public String getDataMatricula() { |
| 104 | + return dataMatricula; |
| 105 | + } |
| 106 | + |
| 107 | + public void setDataMatricula(String dataMatricula) { |
| 108 | + this.dataMatricula = dataMatricula; |
| 109 | + } |
| 110 | + |
| 111 | + public String getNomeEscola() { |
| 112 | + return nomeEscola; |
| 113 | + } |
| 114 | + |
| 115 | + public void setNomeEscola(String nomeEscola) { |
| 116 | + this.nomeEscola = nomeEscola; |
| 117 | + } |
| 118 | + |
| 119 | + public String getSerieMatriculado() { |
| 120 | + return serieMatriculado; |
| 121 | + } |
| 122 | + |
| 123 | + public void setSerieMatriculado(String serieMatriculado) { |
| 124 | + this.serieMatriculado = serieMatriculado; |
| 125 | + } |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | + public double getMedia() { |
| 131 | + |
| 132 | + double somaNota = 0.0; |
| 133 | + for (Disciplina disciplina : disciplinas) { |
| 134 | + somaNota += disciplina.getNota(); |
| 135 | + |
| 136 | + } |
| 137 | + |
| 138 | + return somaNota / disciplinas.size(); |
| 139 | + } |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | + public boolean getResultado() { |
| 144 | + |
| 145 | + double media = this.getMedia(); |
| 146 | + if (media >= 7.0) { |
| 147 | + return true; |
| 148 | + } else { |
| 149 | + return false; |
| 150 | + } |
| 151 | + |
| 152 | + } |
| 153 | + |
| 154 | + @Override |
| 155 | + public String toString() { |
| 156 | + return "Aluno [nome=" + nome + ", idade=" + idade + ", dataNascimento=" |
| 157 | + + dataNascimento + ", registroGeral=" + registroGeral |
| 158 | + + ", numeroCpf=" + numeroCpf + ", nomeMae=" + nomeMae |
| 159 | + + ", nomePai=" + nomePai + ", dataMatricula=" + dataMatricula |
| 160 | + + ", nomeEscola=" + nomeEscola + ", serieMatriculado=" |
| 161 | + + serieMatriculado + ", disciplinas=" + disciplinas + "]"; |
| 162 | + } |
| 163 | + |
| 164 | + @Override |
| 165 | + public int hashCode() { |
| 166 | + final int prime = 31; |
| 167 | + int result = 1; |
| 168 | + result = prime * result |
| 169 | + + ((dataMatricula == null) ? 0 : dataMatricula.hashCode()); |
| 170 | + result = prime * result |
| 171 | + + ((dataNascimento == null) ? 0 : dataNascimento.hashCode()); |
| 172 | + result = prime * result |
| 173 | + + ((disciplinas == null) ? 0 : disciplinas.hashCode()); |
| 174 | + result = prime * result + idade; |
| 175 | + result = prime * result + ((nome == null) ? 0 : nome.hashCode()); |
| 176 | + result = prime * result |
| 177 | + + ((nomeEscola == null) ? 0 : nomeEscola.hashCode()); |
| 178 | + result = prime * result + ((nomeMae == null) ? 0 : nomeMae.hashCode()); |
| 179 | + result = prime * result + ((nomePai == null) ? 0 : nomePai.hashCode()); |
| 180 | + result = prime * result |
| 181 | + + ((numeroCpf == null) ? 0 : numeroCpf.hashCode()); |
| 182 | + result = prime * result |
| 183 | + + ((registroGeral == null) ? 0 : registroGeral.hashCode()); |
| 184 | + result = prime |
| 185 | + * result |
| 186 | + + ((serieMatriculado == null) ? 0 : serieMatriculado.hashCode()); |
| 187 | + return result; |
| 188 | + } |
| 189 | + |
| 190 | + @Override |
| 191 | + public boolean equals(Object obj) { |
| 192 | + if (this == obj) |
| 193 | + return true; |
| 194 | + if (obj == null) |
| 195 | + return false; |
| 196 | + if (getClass() != obj.getClass()) |
| 197 | + return false; |
| 198 | + Aluno other = (Aluno) obj; |
| 199 | + if (dataMatricula == null) { |
| 200 | + if (other.dataMatricula != null) |
| 201 | + return false; |
| 202 | + } else if (!dataMatricula.equals(other.dataMatricula)) |
| 203 | + return false; |
| 204 | + if (dataNascimento == null) { |
| 205 | + if (other.dataNascimento != null) |
| 206 | + return false; |
| 207 | + } else if (!dataNascimento.equals(other.dataNascimento)) |
| 208 | + return false; |
| 209 | + if (disciplinas == null) { |
| 210 | + if (other.disciplinas != null) |
| 211 | + return false; |
| 212 | + } else if (!disciplinas.equals(other.disciplinas)) |
| 213 | + return false; |
| 214 | + if (idade != other.idade) |
| 215 | + return false; |
| 216 | + if (nome == null) { |
| 217 | + if (other.nome != null) |
| 218 | + return false; |
| 219 | + } else if (!nome.equals(other.nome)) |
| 220 | + return false; |
| 221 | + if (nomeEscola == null) { |
| 222 | + if (other.nomeEscola != null) |
| 223 | + return false; |
| 224 | + } else if (!nomeEscola.equals(other.nomeEscola)) |
| 225 | + return false; |
| 226 | + if (nomeMae == null) { |
| 227 | + if (other.nomeMae != null) |
| 228 | + return false; |
| 229 | + } else if (!nomeMae.equals(other.nomeMae)) |
| 230 | + return false; |
| 231 | + if (nomePai == null) { |
| 232 | + if (other.nomePai != null) |
| 233 | + return false; |
| 234 | + } else if (!nomePai.equals(other.nomePai)) |
| 235 | + return false; |
| 236 | + if (numeroCpf == null) { |
| 237 | + if (other.numeroCpf != null) |
| 238 | + return false; |
| 239 | + } else if (!numeroCpf.equals(other.numeroCpf)) |
| 240 | + return false; |
| 241 | + if (registroGeral == null) { |
| 242 | + if (other.registroGeral != null) |
| 243 | + return false; |
| 244 | + } else if (!registroGeral.equals(other.registroGeral)) |
| 245 | + return false; |
| 246 | + if (serieMatriculado == null) { |
| 247 | + if (other.serieMatriculado != null) |
| 248 | + return false; |
| 249 | + } else if (!serieMatriculado.equals(other.serieMatriculado)) |
| 250 | + return false; |
| 251 | + return true; |
| 252 | + } |
| 253 | + |
| 254 | + public List<Bimestre> getBimestres() { |
| 255 | + return bimestres; |
| 256 | + } |
| 257 | + |
| 258 | + public void setBimestres(List<Bimestre> bimestres) { |
| 259 | + this.bimestres = bimestres; |
| 260 | + } |
| 261 | + |
| 262 | + |
| 263 | + |
| 264 | + |
| 265 | +} |
0 commit comments