parent
938d7af3ed
commit
e85b311034
3 changed files with 67 additions and 179 deletions
226
Dados.java
226
Dados.java
|
|
@ -7,10 +7,10 @@ public class Dados {
|
|||
private Bolsista[] bolsistas;
|
||||
|
||||
public Dados(){
|
||||
this.alunos = new Aluno[256];
|
||||
this.chamada = "";
|
||||
this.acompanhamentos = new Acompanhamento[256];
|
||||
this.bolsistas = new Bolsista[256];
|
||||
alunos = new Aluno[]{};
|
||||
chamada = "";
|
||||
acompanhamentos = new Acompanhamento[]{};
|
||||
bolsistas = new Bolsista[]{};
|
||||
}
|
||||
|
||||
public String appendAluno(Aluno aluno){
|
||||
|
|
@ -18,80 +18,62 @@ public class Dados {
|
|||
return Erro.E3;
|
||||
}
|
||||
|
||||
int size = 0;
|
||||
int size = this.alunos.length;
|
||||
|
||||
for (int i = 0; i < this.alunos.length; i++){
|
||||
if (this.alunos[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
Aluno[] novoArray = new Aluno[size + 1];
|
||||
|
||||
for (int i = 0; i < size; i++){
|
||||
novoArray[i] = this.alunos[i];
|
||||
}
|
||||
|
||||
if (size == 255){
|
||||
return Erro.E10;
|
||||
}
|
||||
|
||||
this.alunos[size] = aluno;
|
||||
|
||||
System.out.println("debug_alunos.size:"+size);
|
||||
novoArray[size] = aluno;
|
||||
this.alunos = novoArray;
|
||||
|
||||
return "Aluno cadastrado com sucesso.";
|
||||
}
|
||||
|
||||
public String appendAcompanhamento(Acompanhamento acomp){
|
||||
|
||||
int size = 0;
|
||||
|
||||
for (int i = 0; i < this.acompanhamentos.length; i++){
|
||||
if (this.acompanhamentos[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
if (checkDuplicate(acomp.getAluno().getNome())){
|
||||
return Erro.E3;
|
||||
}
|
||||
|
||||
if (size == 255){
|
||||
return Erro.E10;
|
||||
int size = this.acompanhamentos.length;
|
||||
|
||||
Acompanhamento[] novoArray = new Acompanhamento[size + 1];
|
||||
|
||||
for (int i = 0; i < size; i++){
|
||||
novoArray[i] = this.acompanhamentos[i];
|
||||
}
|
||||
|
||||
this.acompanhamentos[size] = acomp;
|
||||
|
||||
System.out.println("debug_acompanhamentos.size:"+size);
|
||||
novoArray[size] = acomp;
|
||||
this.acompanhamentos = novoArray;
|
||||
|
||||
return "Acompanhamento cadastrado com sucesso.";
|
||||
}
|
||||
|
||||
public String appendBolsista(Bolsista bolsista){
|
||||
|
||||
int size = 0;
|
||||
|
||||
for (int i = 0; i < this.bolsistas.length; i++){
|
||||
if (this.bolsistas[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
if (checkDuplicate(bolsista.getNome())){
|
||||
return Erro.E3;
|
||||
}
|
||||
|
||||
if (size == 255){
|
||||
return Erro.E10;
|
||||
int size = this.bolsistas.length;
|
||||
|
||||
Bolsista[] novoArray = new Bolsista[size + 1];
|
||||
|
||||
for (int i = 0; i < size; i++){
|
||||
novoArray[i] = this.bolsistas[i];
|
||||
}
|
||||
|
||||
this.bolsistas[size] = bolsista;
|
||||
novoArray[size] = bolsista;
|
||||
this.bolsistas = novoArray;
|
||||
|
||||
return "Bolsista cadastrado com sucesso.";
|
||||
|
||||
|
||||
}
|
||||
|
||||
private boolean checkDuplicate(String nome){
|
||||
|
||||
int size = 0;
|
||||
|
||||
for (int i = 0; i < this.alunos.length; i++){
|
||||
if (this.alunos[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < size; i++){
|
||||
for (int i = 0; i < alunos.length; i++){
|
||||
if (nome.equals(alunos[i].getNome())){
|
||||
return true;
|
||||
}
|
||||
|
|
@ -101,17 +83,7 @@ public class Dados {
|
|||
}
|
||||
|
||||
private int findAlunoIndex(String nome){
|
||||
|
||||
int size = 0;
|
||||
|
||||
for (int i = 0; i < this.alunos.length; i++){
|
||||
if (this.alunos[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < size; i++){
|
||||
for (int i = 0; i < alunos.length; i++){
|
||||
if (nome.equals(alunos[i].getNome()))
|
||||
return i;
|
||||
}
|
||||
|
|
@ -129,20 +101,8 @@ public class Dados {
|
|||
}
|
||||
|
||||
public Acompanhamento findAcompanhamento(String nome){
|
||||
|
||||
int size = 0;
|
||||
|
||||
for (int i = 0; i < this.acompanhamentos.length; i++){
|
||||
if (this.acompanhamentos[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("debug_acompanhamentos.size:"+size);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (this.acompanhamentos[i].getAluno().getNome().equals(nome)) {
|
||||
for (int i = 0; i < acompanhamentos.length; i++){
|
||||
if (acompanhamentos[i].getAluno().getNome().equals(nome)) {
|
||||
return acompanhamentos[i];
|
||||
}
|
||||
}
|
||||
|
|
@ -151,19 +111,11 @@ public class Dados {
|
|||
}
|
||||
|
||||
public String listAlunos(){
|
||||
int size = 0;
|
||||
for (int i = 0; i < this.alunos.length; i++){
|
||||
if (this.alunos[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
if (alunos.length == 0)
|
||||
return Erro.E5;
|
||||
|
||||
String lista = "";
|
||||
for (int i = 0; i < size; i++){
|
||||
for (int i = 0; i < alunos.length; i++){
|
||||
lista = lista.concat(alunos[i].getNome() + "\n");
|
||||
}
|
||||
|
||||
|
|
@ -171,20 +123,11 @@ public class Dados {
|
|||
}
|
||||
|
||||
public String listBolsistas(){
|
||||
int size = 0;
|
||||
|
||||
for (int i = 0; i < this.bolsistas.length; i++){
|
||||
if (this.bolsistas[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
if (bolsistas.length == 0)
|
||||
return Erro.E5;
|
||||
|
||||
String lista = "";
|
||||
for (int i = 0; i < size; i++){
|
||||
for (int i = 0; i < bolsistas.length; i++){
|
||||
lista = lista.concat(bolsistas[i].getNome());
|
||||
}
|
||||
|
||||
|
|
@ -192,20 +135,12 @@ public class Dados {
|
|||
}
|
||||
|
||||
public String riskReport(){
|
||||
int size = 0;
|
||||
for (int i = 0; i < this.acompanhamentos.length; i++){
|
||||
if (this.acompanhamentos[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
if (acompanhamentos.length == 0)
|
||||
return Erro.E8;
|
||||
|
||||
String relatorio = "";
|
||||
|
||||
for (int i = 0; i < size; i++){
|
||||
for (int i = 0; i < acompanhamentos.length; i++){
|
||||
relatorio = relatorio.concat(acompanhamentos[i].getAluno().getNome() + ": Risco ");
|
||||
relatorio = relatorio.concat(acompanhamentos[i].getRiscoLabel() + "\n");
|
||||
}
|
||||
|
|
@ -215,20 +150,12 @@ public class Dados {
|
|||
}
|
||||
|
||||
public String riskReportHigh(){
|
||||
int size = 0;
|
||||
for (int i = 0; i < this.acompanhamentos.length; i++){
|
||||
if (this.acompanhamentos[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
if (acompanhamentos.length == 0)
|
||||
return Erro.E8;
|
||||
|
||||
String relatorio = "";
|
||||
|
||||
for (int i = 0; i < size; i++){
|
||||
for (int i = 0; i < acompanhamentos.length; i++){
|
||||
if (acompanhamentos[i].getRiscoLabel().equals("ALTO")){
|
||||
relatorio = relatorio.concat(acompanhamentos[i].getAluno().getNome() + ": Risco ALTO\n");
|
||||
}
|
||||
|
|
@ -241,21 +168,11 @@ public class Dados {
|
|||
}
|
||||
|
||||
public String maiorNome(){
|
||||
int size = 0;
|
||||
for (int i = 0; i < this.alunos.length; i++){
|
||||
if (this.alunos[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
if (alunos.length == 0)
|
||||
return Erro.E5;
|
||||
if (size == 1)
|
||||
return alunos[0].getNome();
|
||||
|
||||
int k = 0;
|
||||
for (int i = 1; i < size; i++){
|
||||
for (int i = 1; i < alunos.length; i++){
|
||||
if (alunos[i].getNome().length() > alunos[k].getNome().length())
|
||||
k = i;
|
||||
}
|
||||
|
|
@ -263,42 +180,26 @@ public class Dados {
|
|||
}
|
||||
|
||||
public String averageAge(){
|
||||
int size = 0;
|
||||
for (int i = 0; i < this.alunos.length; i++){
|
||||
if (this.alunos[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
if (alunos.length == 0)
|
||||
return Erro.E5;
|
||||
|
||||
double sum = 0;
|
||||
|
||||
for (int i = 0; i < size; i++){
|
||||
for (int i = 0; i < alunos.length; i++){
|
||||
sum += alunos[i].getIdade();
|
||||
}
|
||||
|
||||
sum = sum / size;
|
||||
sum = sum / alunos.length;
|
||||
return "Idade média dos alunos: " + sum;
|
||||
}
|
||||
|
||||
public String totalVowels(){
|
||||
int size = 0;
|
||||
for (int i = 0; i < this.alunos.length; i++){
|
||||
if (this.alunos[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
if (alunos.length == 0)
|
||||
return Erro.E5;
|
||||
|
||||
int sum = 0;
|
||||
|
||||
for (int k = 0; k < size; k++){
|
||||
for (int k = 0; k < alunos.length; k++){
|
||||
String nome = alunos[k].getNome();
|
||||
|
||||
for (int j = 0; j < nome.length(); j++){
|
||||
|
|
@ -320,18 +221,10 @@ public class Dados {
|
|||
public void makeChamada(){
|
||||
this.chamada = "";
|
||||
|
||||
int size = 0;
|
||||
for (int i = 0; i < this.alunos.length; i++){
|
||||
if (this.alunos[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0){
|
||||
if (alunos.length == 0){
|
||||
this.chamada = Erro.E5;
|
||||
} else {
|
||||
for (int i = 0; i < size; i++){
|
||||
for (int i = 0; i < alunos.length; i++){
|
||||
this.chamada = this.chamada.concat(alunos[i].getMatricula() + " / ");
|
||||
this.chamada = this.chamada.concat(alunos[i].getNome() + " / ");
|
||||
this.chamada = this.chamada.concat(alunos[i].getCurso() + "\n");
|
||||
|
|
@ -348,19 +241,12 @@ public class Dados {
|
|||
|
||||
public double coursePercent(String curso){
|
||||
double num = 0;
|
||||
int size = 0;
|
||||
for (int i = 0; i < this.alunos.length; i++){
|
||||
if (this.alunos[i] == null){
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < size; i++){
|
||||
for (int i = 0; i < alunos.length; i++){
|
||||
if (alunos[i].getCurso().equals(curso))
|
||||
num++;
|
||||
}
|
||||
|
||||
return (num / size) * 100;
|
||||
return (num / alunos.length) * 100;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,5 +8,4 @@ public class Erro {
|
|||
public static final String E7 = "Erro: Não foi possível calcular o risco pedagógico.";
|
||||
public static final String E8 = "Erro: Não existem acompanhamentos cadastrados.";
|
||||
public static final String E9 = "Erro: Não existe nenhum aluno com risco alto.";
|
||||
public static final String E10 = "Erro: Numero máximo de alunos atingido.";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,16 +6,15 @@ public class Gerenciador {
|
|||
private Dados dados;
|
||||
private static Scanner input = new Scanner(System.in);
|
||||
|
||||
|
||||
String nome = "", local = "", curso = "", matricula = "", projeto = "", orientador = "";
|
||||
int idade = 0, semestre = 0, ano = 0;
|
||||
boolean bolsista = false;
|
||||
|
||||
public Gerenciador(Dados dados) {
|
||||
this.dados = dados;
|
||||
}
|
||||
|
||||
public String cadastrarAluno() {
|
||||
String nome = "", local = "", curso = "", matricula = "";
|
||||
int idade = 0, semestre = 0, ano = 0;
|
||||
|
||||
while (nome.length() == 0){
|
||||
System.out.println("Insira o nome do aluno:");
|
||||
nome = input.nextLine();}
|
||||
|
|
@ -61,7 +60,6 @@ public class Gerenciador {
|
|||
}
|
||||
|
||||
public String cadastrarBolsista(boolean resposta, Aluno alunoparametro) {
|
||||
String projeto = "", orientador = "";
|
||||
|
||||
Aluno aluno;
|
||||
|
||||
|
|
@ -76,11 +74,11 @@ public class Gerenciador {
|
|||
|
||||
while (projeto.length() == 0){
|
||||
System.out.println("Insira o nome do projeto:");
|
||||
projeto = input.nextLine();}
|
||||
String projeto = input.nextLine();}
|
||||
|
||||
while (orientador.length() == 0){
|
||||
System.out.println("Insira o nome do orientador:");
|
||||
orientador = input.nextLine();}
|
||||
String orientador = input.nextLine();}
|
||||
|
||||
Bolsista bolsista = new Bolsista(aluno, projeto, orientador);
|
||||
aluno.setBolsista(true);
|
||||
|
|
@ -127,7 +125,12 @@ public class Gerenciador {
|
|||
if (acomp.setAtividadesNaoEstudadas(naoestudadas))
|
||||
return Erro.E4;
|
||||
|
||||
return this.dados.appendAcompanhamento(acomp);
|
||||
if (ia + explicadas + semajuda + naoestudadas > entregues)
|
||||
return Erro.E4;
|
||||
|
||||
this.dados.appendAcompanhamento(acomp);
|
||||
return "Acompanhamento registrado com sucesso.";
|
||||
|
||||
}
|
||||
|
||||
public String listarAlunos() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue