fixed appends
This commit is contained in:
parent
e85b311034
commit
51289aff1e
4 changed files with 61 additions and 98 deletions
|
|
@ -7,86 +7,50 @@ public class Acompanhamento {
|
||||||
private int atividadesNaoEstudadas;
|
private int atividadesNaoEstudadas;
|
||||||
private double riscoPedagogico;
|
private double riscoPedagogico;
|
||||||
|
|
||||||
public Acompanhamento(Aluno aluno, int atividadesEntregues, int atividadesIA, int atividadesExplicadas,
|
public Acompanhamento(Aluno aluno, int atividadesEntregues, int atividadesIA, int atividadesExplicadas, int atividadesSemAjuda, int atividadesNaoEstudadas){
|
||||||
int atividadesSemAjuda, int atividadesNaoEstudadas) {
|
|
||||||
this.aluno = aluno;
|
this.aluno = aluno;
|
||||||
this.atividadesEntregues = atividadesEntregues;
|
this.atividadesEntregues = atividadesEntregues;
|
||||||
this.atividadesIA = atividadesIA;
|
this.atividadesIA = atividadesIA;
|
||||||
this.atividadesExplicadas = atividadesExplicadas;
|
this.atividadesExplicadas = atividadesExplicadas;
|
||||||
this.atividadesSemAjuda = atividadesSemAjuda;
|
this.atividadesSemAjuda = atividadesSemAjuda;
|
||||||
this.atividadesNaoEstudadas = atividadesNaoEstudadas;
|
this.atividadesNaoEstudadas = atividadesNaoEstudadas;
|
||||||
|
|
||||||
|
this.riscoPedagogico = this.calcularRisco();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calcularRisco() {
|
private double calcularRisco(){
|
||||||
double razaoIa = atividadesIA / atividadesEntregues;
|
double razaoIa = (double) atividadesIA / (double) atividadesEntregues;
|
||||||
double razaoNaoExplicadas = (atividadesEntregues - atividadesExplicadas) / atividadesEntregues;
|
double razaoNaoExplicadas = (double) (atividadesEntregues - atividadesExplicadas) / (double) atividadesEntregues;
|
||||||
double razaoComAjuda = (atividadesEntregues - atividadesSemAjuda) / atividadesEntregues;
|
double razaoComAjuda = (double) (atividadesEntregues - atividadesSemAjuda) / (double) atividadesEntregues;
|
||||||
double razaoNaoEstudadas = atividadesNaoEstudadas / atividadesEntregues;
|
double razaoNaoEstudadas = (double) atividadesNaoEstudadas / (double) atividadesEntregues;
|
||||||
double media = (razaoIa + razaoNaoExplicadas + razaoComAjuda + razaoNaoEstudadas) / 4;
|
double media = (razaoIa + razaoNaoExplicadas + razaoComAjuda + razaoNaoEstudadas) / (double) 4;
|
||||||
this.riscoPedagogico = media * 10;
|
|
||||||
|
|
||||||
|
return media * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getRiscoPedagogico() {
|
public double getRiscoPedagogico(){
|
||||||
this.calcularRisco();
|
return this.calcularRisco();
|
||||||
return riscoPedagogico;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRiscoLabel() {
|
public String getRiscoLabel(){
|
||||||
this.calcularRisco();
|
this.riscoPedagogico = this.calcularRisco();
|
||||||
if (riscoPedagogico <= 3.3) {
|
|
||||||
|
if (this.riscoPedagogico <= 3.3){
|
||||||
return "O risco pedagógico deste aluno é BAIXO";
|
return "O risco pedagógico deste aluno é BAIXO";
|
||||||
}
|
}
|
||||||
if (riscoPedagogico > 3.3 && riscoPedagogico < 6.6) {
|
if (this.riscoPedagogico > 3.3 && this.riscoPedagogico < 6.6){
|
||||||
return "O risco pedagógico deste aluno é MODERADO";
|
return "O risco pedagógico deste aluno é MODERADO";
|
||||||
}
|
}
|
||||||
if (riscoPedagogico >= 6.6) {
|
if (this.riscoPedagogico >= 6.6){
|
||||||
return "O risco pedagógico deste aluno é ALTO";
|
return "O risco pedagógico deste aluno é ALTO";
|
||||||
}
|
}
|
||||||
|
|
||||||
return Erro.E7;
|
return Erro.E7;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Aluno getAluno() {
|
public Aluno getAluno(){
|
||||||
return this.aluno;
|
return this.aluno;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAluno(Aluno aluno) {
|
|
||||||
this.aluno = aluno;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAtividadesEntregues(int atividadesEntregues) {
|
|
||||||
this.atividadesEntregues = atividadesEntregues;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setAtividadesIA(int atividadesIA) {
|
|
||||||
if (atividadesIA > atividadesEntregues) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
this.atividadesIA = atividadesIA;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setAtividadesExplicadas(int atividadesExplicadas) {
|
|
||||||
if (atividadesExplicadas > atividadesEntregues) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
this.atividadesExplicadas = atividadesExplicadas;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setAtividadesSemAjuda(int atividadesSemAjuda) {
|
|
||||||
if (atividadesSemAjuda > atividadesEntregues) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
this.atividadesSemAjuda = atividadesSemAjuda;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setAtividadesNaoEstudadas(int atividadesNaoEstudadas) {
|
|
||||||
if (atividadesNaoEstudadas > atividadesEntregues) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
this.atividadesNaoEstudadas = atividadesNaoEstudadas;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
36
Dados.java
36
Dados.java
|
|
@ -33,8 +33,12 @@ public class Dados {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String appendAcompanhamento(Acompanhamento acomp){
|
public String appendAcompanhamento(Acompanhamento acomp){
|
||||||
if (checkDuplicate(acomp.getAluno().getNome())){
|
|
||||||
return Erro.E3;
|
int index = findAcompanhamentoIndex(acomp.getAluno().getNome());
|
||||||
|
|
||||||
|
if (index != -1){
|
||||||
|
acompanhamentos[index] = acomp;
|
||||||
|
return "Acompanhamento atualizado com sucesso.";
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = this.acompanhamentos.length;
|
int size = this.acompanhamentos.length;
|
||||||
|
|
@ -51,10 +55,15 @@ public class Dados {
|
||||||
return "Acompanhamento cadastrado com sucesso.";
|
return "Acompanhamento cadastrado com sucesso.";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String appendBolsista(Bolsista bolsista){
|
public int findAcompanhamentoIndex(String nome){
|
||||||
if (checkDuplicate(bolsista.getNome())){
|
for (int i = 0; i < acompanhamentos.length; i++){
|
||||||
return Erro.E3;
|
if (nome.equals(acompanhamentos[i].getAluno().getNome()))
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String appendBolsista(Bolsista bolsista){
|
||||||
|
|
||||||
int size = this.bolsistas.length;
|
int size = this.bolsistas.length;
|
||||||
|
|
||||||
|
|
@ -68,8 +77,6 @@ public class Dados {
|
||||||
this.bolsistas = novoArray;
|
this.bolsistas = novoArray;
|
||||||
|
|
||||||
return "Bolsista cadastrado com sucesso.";
|
return "Bolsista cadastrado com sucesso.";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkDuplicate(String nome){
|
private boolean checkDuplicate(String nome){
|
||||||
|
|
@ -101,13 +108,12 @@ public class Dados {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Acompanhamento findAcompanhamento(String nome){
|
public Acompanhamento findAcompanhamento(String nome){
|
||||||
for (int i = 0; i < acompanhamentos.length; i++){
|
int index = findAcompanhamentoIndex(nome);
|
||||||
if (acompanhamentos[i].getAluno().getNome().equals(nome)) {
|
|
||||||
return acompanhamentos[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
if (index == -1)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return acompanhamentos[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public String listAlunos(){
|
public String listAlunos(){
|
||||||
|
|
@ -141,7 +147,7 @@ public class Dados {
|
||||||
String relatorio = "";
|
String relatorio = "";
|
||||||
|
|
||||||
for (int i = 0; i < acompanhamentos.length; i++){
|
for (int i = 0; i < acompanhamentos.length; i++){
|
||||||
relatorio = relatorio.concat(acompanhamentos[i].getAluno().getNome() + ": Risco ");
|
relatorio = relatorio.concat(acompanhamentos[i].getAluno().getNome());
|
||||||
relatorio = relatorio.concat(acompanhamentos[i].getRiscoLabel() + "\n");
|
relatorio = relatorio.concat(acompanhamentos[i].getRiscoLabel() + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,6 +176,8 @@ public class Dados {
|
||||||
public String maiorNome(){
|
public String maiorNome(){
|
||||||
if (alunos.length == 0)
|
if (alunos.length == 0)
|
||||||
return Erro.E5;
|
return Erro.E5;
|
||||||
|
if (alunos.length == 1)
|
||||||
|
return alunos[0].getNome();
|
||||||
|
|
||||||
int k = 0;
|
int k = 0;
|
||||||
for (int i = 1; i < alunos.length; i++){
|
for (int i = 1; i < alunos.length; i++){
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,11 @@ public class Erro {
|
||||||
public static final String E1 = "Erro: Opção do menu inválida.";
|
public static final String E1 = "Erro: Opção do menu inválida.";
|
||||||
public static final String E2 = "Erro: Aluno não encontrado.";
|
public static final String E2 = "Erro: Aluno não encontrado.";
|
||||||
public static final String E3 = "Erro: Já existe um aluno com esse nome.";
|
public static final String E3 = "Erro: Já existe um aluno com esse nome.";
|
||||||
public static final String E4 = "Erro: Você escolheu um número maior do que o total de atividades entregues.";
|
public static final String E4 = "Erro: Você inseriu numeros inválidos de atividades.";
|
||||||
public static final String E5 = "Erro: Não existem alunos cadastrados.";
|
public static final String E5 = "Erro: Não existem alunos cadastrados.";
|
||||||
public static final String E6 = "Erro: Nenhuma chamada foi criada.";
|
public static final String E6 = "Erro: Nenhuma chamada foi criada.";
|
||||||
public static final String E7 = "Erro: Não foi possível calcular o risco pedagógico.";
|
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 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 E9 = "Erro: Não existe nenhum aluno com risco alto.";
|
||||||
|
public static final String E10 = "Erro: Acompanhamento não encontrado.";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,19 @@
|
||||||
// TODO: buffer clears
|
|
||||||
|
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Gerenciador {
|
public class Gerenciador {
|
||||||
private Dados dados;
|
private Dados dados;
|
||||||
private static Scanner input = new Scanner(System.in);
|
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) {
|
public Gerenciador(Dados dados) {
|
||||||
this.dados = dados;
|
this.dados = dados;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String cadastrarAluno() {
|
public String cadastrarAluno() {
|
||||||
|
String nome = "", local = "", curso = "", matricula = "";
|
||||||
|
int idade = 0, semestre = 0, ano = 0;
|
||||||
|
|
||||||
while (nome.length() == 0){
|
while (nome.length() == 0){
|
||||||
System.out.println("Insira o nome do aluno:");
|
System.out.println("Insira o nome do aluno:");
|
||||||
nome = input.nextLine();}
|
nome = input.nextLine();}
|
||||||
|
|
@ -60,6 +59,7 @@ public class Gerenciador {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String cadastrarBolsista(boolean resposta, Aluno alunoparametro) {
|
public String cadastrarBolsista(boolean resposta, Aluno alunoparametro) {
|
||||||
|
String projeto = "", orientador = "";
|
||||||
|
|
||||||
Aluno aluno;
|
Aluno aluno;
|
||||||
|
|
||||||
|
|
@ -74,11 +74,11 @@ public class Gerenciador {
|
||||||
|
|
||||||
while (projeto.length() == 0){
|
while (projeto.length() == 0){
|
||||||
System.out.println("Insira o nome do projeto:");
|
System.out.println("Insira o nome do projeto:");
|
||||||
String projeto = input.nextLine();}
|
projeto = input.nextLine();}
|
||||||
|
|
||||||
while (orientador.length() == 0){
|
while (orientador.length() == 0){
|
||||||
System.out.println("Insira o nome do orientador:");
|
System.out.println("Insira o nome do orientador:");
|
||||||
String orientador = input.nextLine();}
|
orientador = input.nextLine();}
|
||||||
|
|
||||||
Bolsista bolsista = new Bolsista(aluno, projeto, orientador);
|
Bolsista bolsista = new Bolsista(aluno, projeto, orientador);
|
||||||
aluno.setBolsista(true);
|
aluno.setBolsista(true);
|
||||||
|
|
@ -94,43 +94,33 @@ public class Gerenciador {
|
||||||
if (aluno == null)
|
if (aluno == null)
|
||||||
return Erro.E2;
|
return Erro.E2;
|
||||||
|
|
||||||
Acompanhamento acomp = new Acompanhamento(aluno, 0, 0, 0, 0, 0);
|
|
||||||
|
|
||||||
System.out.println("Insira a quantidade de atividades entregues:");
|
System.out.println("Insira a quantidade de atividades entregues:");
|
||||||
int entregues = input.nextInt();
|
int entregues = input.nextInt();
|
||||||
input.nextLine(); //buffer clear
|
input.nextLine(); //buffer clear
|
||||||
acomp.setAtividadesEntregues(entregues);
|
|
||||||
|
|
||||||
System.out.println("Insira a quantidade de atividades entregues nas quais foi declarado o uso de IA:");
|
System.out.println("Insira a quantidade de atividades entregues nas quais foi declarado o uso de IA:");
|
||||||
int ia = input.nextInt();
|
int ia = input.nextInt();
|
||||||
input.nextLine(); //buffer clear
|
input.nextLine(); //buffer clear
|
||||||
if (acomp.setAtividadesIA(ia))
|
|
||||||
return Erro.E4;
|
|
||||||
|
|
||||||
System.out.println("Insira a quantidade de atividades entregues que o aluno soube explicar:");
|
System.out.println("Insira a quantidade de atividades entregues que o aluno soube explicar:");
|
||||||
int explicadas = input.nextInt();
|
int explicadas = input.nextInt();
|
||||||
input.nextLine(); //buffer clear
|
input.nextLine(); //buffer clear
|
||||||
if (acomp.setAtividadesExplicadas(explicadas))
|
|
||||||
return Erro.E4;
|
|
||||||
|
|
||||||
System.out.println("Insira a quantidade de atividades entregues que foram feitas sem ajuda:");
|
System.out.println("Insira a quantidade de atividades entregues que foram feitas sem ajuda:");
|
||||||
int semajuda = input.nextInt();
|
int semajuda = input.nextInt();
|
||||||
input.nextLine(); //buffer clear
|
input.nextLine(); //buffer clear
|
||||||
if (acomp.setAtividadesSemAjuda(semajuda))
|
|
||||||
return Erro.E4;
|
|
||||||
|
|
||||||
System.out.println("Insira a quanntidade de atividades entregues que utilizarão estruturas não estudadas:");
|
System.out.println("Insira a quanntidade de atividades entregues que utilizaram estruturas não estudadas:");
|
||||||
int naoestudadas = input.nextInt();
|
int naoestudadas = input.nextInt();
|
||||||
input.nextLine(); //buffer clear
|
input.nextLine(); //buffer clear
|
||||||
if (acomp.setAtividadesNaoEstudadas(naoestudadas))
|
|
||||||
|
if (ia > entregues || explicadas > entregues || semajuda > entregues || naoestudadas > entregues){
|
||||||
return Erro.E4;
|
return Erro.E4;
|
||||||
|
}
|
||||||
|
|
||||||
if (ia + explicadas + semajuda + naoestudadas > entregues)
|
Acompanhamento acomp = new Acompanhamento(aluno, entregues, ia, explicadas, semajuda, naoestudadas);
|
||||||
return Erro.E4;
|
|
||||||
|
|
||||||
this.dados.appendAcompanhamento(acomp);
|
|
||||||
return "Acompanhamento registrado com sucesso.";
|
|
||||||
|
|
||||||
|
return this.dados.appendAcompanhamento(acomp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String listarAlunos() {
|
public String listarAlunos() {
|
||||||
|
|
@ -183,7 +173,7 @@ public class Gerenciador {
|
||||||
System.out.println("Insira o nome de um aluno:");
|
System.out.println("Insira o nome de um aluno:");
|
||||||
Acompanhamento acomp = this.dados.findAcompanhamento(input.nextLine());
|
Acompanhamento acomp = this.dados.findAcompanhamento(input.nextLine());
|
||||||
if (acomp == null)
|
if (acomp == null)
|
||||||
return Erro.E2;
|
return Erro.E10;
|
||||||
|
|
||||||
return acomp.getRiscoLabel();
|
return acomp.getRiscoLabel();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue