tf_fundamentos/Gerenciador.java
caioperschespindola 0b5ff1b326 Revisado
2026-07-03 13:40:23 -03:00

197 lines
No EOL
6.1 KiB
Java

import java.util.Scanner;
public class Gerenciador {
private Dados dados;
private static Scanner input = new Scanner(System.in);
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){// Repete a pergunta até que uma resposta seja digitada
System.out.println("Insira o nome do aluno:");
nome = input.nextLine();}
while (local.length() == 0){// Repete a pergunta até que uma resposta seja digitada
System.out.println("Insira o local de nascimento do aluno:");
local = input.nextLine();}
while (curso.length() == 0){// Repete a pergunta até que uma resposta seja digitada
System.out.println("Insira o curso do aluno:");
curso = input.nextLine();}
while (matricula.length() == 0){// Repete a pergunta até que uma resposta seja digitada
System.out.println("Insira a matricula do aluno:");
matricula = input.nextLine();}
while (idade == 0 ){// Repete a pergunta até que uma resposta seja digitada
System.out.println("Insira a idade do aluno:");
idade = input.nextInt();
input.nextLine(); //buffer clear
if (idade < 0) {return Erro.E11;}}
while (semestre == 0){// Repete a pergunta até que uma resposta seja digitada
System.out.println("Insira o semestre do aluno:");
semestre = input.nextInt();
input.nextLine(); //buffer clear
if (semestre < 0) {return Erro.E11;}}
while (ano == 0){// Repete a pergunta até que uma resposta seja digitada
System.out.println("Insira o ano do aluno:");
ano = input.nextInt();
input.nextLine(); //buffer clear
if (ano < 0) {return Erro.E11;}}
Aluno aluno = new Aluno(nome, idade, local, curso, matricula, semestre, ano, false);
String msg = this.dados.appendAluno(aluno);
System.out.println("O aluno eh bolsista? (s/n)");
String resposta = input.nextLine().toLowerCase();
if (resposta.equals("s")){
return cadastrarBolsista(true, aluno);
}
return msg;
}
public String cadastrarBolsista(boolean resposta, Aluno alunoparametro) {
String projeto = "", orientador = "";
Aluno aluno;
if (resposta){
aluno = alunoparametro;
} else {
System.out.println("Insira o nome do aluno a quem voce deseja cadastrar uma bolsa:");
aluno = this.dados.findAluno(input.nextLine());
if (aluno == null) {return Erro.E2;}
}
while (projeto.length() == 0){// Repete a pergunta até que uma resposta seja digitada
System.out.println("Insira o nome do projeto:");
projeto = input.nextLine();}
while (orientador.length() == 0){// Repete a pergunta até que uma resposta seja digitada
System.out.println("Insira o nome do orientador:");
orientador = input.nextLine();}
Bolsista bolsista = new Bolsista(aluno, projeto, orientador);
aluno.setBolsista(true);
return this.dados.appendBolsista(bolsista);
}
public String registrarAcompanhamento() {
System.out.println("Insira o nome do Aluno que voce deseja registrar o acompanhamento:");
String nome = input.nextLine();
Aluno aluno = this.dados.findAluno(nome);
if (aluno == null) {return Erro.E2;}
System.out.println("Insira a quantidade de atividades entregues:");
int entregues = input.nextInt();
input.nextLine(); //buffer clear
if (entregues < 0) {return Erro.E11;}
System.out.println("Insira a quantidade de atividades entregues nas quais foi declarado o uso de IA:");
int ia = input.nextInt();
input.nextLine(); //buffer clear
if (ia < 0) {return Erro.E11;}
System.out.println("Insira a quantidade de atividades entregues que o aluno soube explicar:");
int explicadas = input.nextInt();
input.nextLine(); //buffer clear
if (explicadas < 0) {return Erro.E11;}
System.out.println("Insira a quantidade de atividades entregues que foram feitas sem ajuda:");
int semajuda = input.nextInt();
input.nextLine(); //buffer clear
if (semajuda < 0) {return Erro.E11;}
System.out.println("Insira a quantidade de atividades entregues que utilizaram estruturas não estudadas:");
int naoestudadas = input.nextInt();
input.nextLine(); //buffer clear
if (naoestudadas < 0) {return Erro.E11;}
if (ia > entregues || explicadas > entregues || semajuda > entregues || naoestudadas > entregues){
return Erro.E4;
}
Acompanhamento acomp = new Acompanhamento(aluno, entregues, ia, explicadas, semajuda, naoestudadas);
return this.dados.appendAcompanhamento(acomp);
}
public String listarAlunos() {
return this.dados.listAlunos();
}
public String listarBolsistas() {
return this.dados.listBolsistas();
}
public String maiorNome(){
return this.dados.maiorNome();
}
public String vogaisNomes(){
return this.dados.totalVowels();
}
public String percentualAlunos() {
String curso = "";
while (curso.length() == 0){// Repete a pergunta até que uma resposta seja digitada
System.out.println("Insira um curso:");
curso = input.nextLine();
}
double porcentagem = this.dados.coursePercent(curso);
if (porcentagem == -1) {return Erro.E5;}
return "O percentual de alunos matriculados nesse curso eh de: " + porcentagem + "%";
}
public String mediaIdadeAlunos() {
return this.dados.averageAge();
}
public String criarChamada() {
this.dados.makeChamada();
if (this.dados.getChamada().length() == 0) {return Erro.E5;}
return "Chamada criada com sucesso.";
}
public String chamada() {
return this.dados.printChamada();
}
public String calcularRisco() {
System.out.println("Insira o nome de um aluno:");
Acompanhamento acomp = this.dados.findAcompanhamento(input.nextLine());
if (acomp == null) {return Erro.E10;}
return acomp.getRiscoLabel();
}
public String relatorioRisco() {
return this.dados.riskReport();
}
public String altoRisco() {
return this.dados.riskReportHigh();
}
public String inovacao() {
return dados.rankingRisco();
}
}