Revert "gerenciador-rev"

This reverts commit 85aabf555e.
This commit is contained in:
caioperschespindola 2026-06-11 18:58:29 -03:00
parent 85aabf555e
commit 68a1209f70
6 changed files with 21 additions and 139 deletions

View file

@ -6,7 +6,7 @@ public class Aluno {
private int ano; private int ano;
private boolean bolsista; private boolean bolsista;
public Aluno(String nome, int idade, String localNascimento, String curso, String matricula, int semestre, int ano, boolean bolsista){ public Aluno(int nome, int idade, String localNascimento, String curso, String matricula, int semestre, int ano, boolean bolsista){
this.pessoa = new Pessoa(nome, idade, localNascimento); this.pessoa = new Pessoa(nome, idade, localNascimento);
this.curso = curso; this.curso = curso;
this.matricula = matricula; this.matricula = matricula;
@ -15,7 +15,7 @@ public class Aluno {
this.bolsista = bolsista; this.bolsista = bolsista;
} }
public String getNome(){ public int getNome(){
return this.pessoa.getNome(); return this.pessoa.getNome();
} }

View file

@ -3,13 +3,13 @@ public class Bolsista{
private String projeto; private String projeto;
private String orientador; private String orientador;
public Bolsista(String nome, int idade, String localNascimento, String curso, String matricula, int semestre, int ano, boolean bolsista, String projeto, String orientador){ public Bolsista(int nome, int idade, String localNascimento, String curso, String matricula, int semestre, int ano, boolean bolsista, String projeto, String orientador){
this.aluno = new Aluno(nome, idade, localNascimento, curso, matricula, semestre, ano, bolsista); this.aluno = new Aluno(nome, idade, localNascimento, curso, matricula, semestre, ano, bolsista);
this.projeto = projeto; this.projeto = projeto;
this.orientador = orientador; this.orientador = orientador;
} }
public String getNome(){ public int getNome(){
return this.aluno.getNome(); return this.aluno.getNome();
} }

View file

@ -1,95 +1,2 @@
public class Dados { public class Dados {
private Aluno[] alunos;
private String chamada;
public Dados(){
alunos = new Aluno[]{};
chamada = "";
}
public void appendAluno(Aluno aluno){
int size = this.alunos.length;
Aluno[] novoArray = new Aluno[size + 1];
for (int i = 0; i < size; i++){
novoArray[i] = this.alunos[i];
}
novoArray[size] = aluno;
this.alunos = novoArray;
}
private int findAlunoIndex(String nome){
for (int i = 0; i < alunos.length; i++){
if (nome.equals(alunos[i].getNome()))
return i;
}
return -1;
}
public void listAlunos(){
for (int i = 0; i < alunos.length; i++){
System.out.println(alunos[i].getNome());
}
}
public void listBolsistas(){
for (int i = 0; i < alunos.length; i++){
if (alunos[i].getBolsista())
System.out.println(alunos[i].getNome());
}
}
public void maiorNome(){
int k = 0;
for (int i = 1; i < alunos.length; i++){
if (alunos[i].getNome().length() > alunos[k].getNome().length())
k = i;
}
System.out.println(alunos[k].getNome());
}
public double averageAge(){
double sum = 0;
for (int i = 0; i < alunos.length; i++){
sum += alunos[i].getIdade();
}
sum = sum / alunos.length;
return sum;
}
public int totalVowels(){
char[] vowels = new char[]{'a', 'e', 'i', 'o', 'u'};
int sum = 0;
for (int i = 0; i < vowels.length; i++){
for (int k = 0; k < alunos.length; k++){
String nome = alunos[k].getNome();
for (int j = 0; j < nome.length(); j++){
if (nome.charAt(j) == vowels[i]){
sum++;}
}
}
}
return sum;
}
public void makeChamada(){
this.chamada = "";
for (int i = 0; i < alunos.length; i++){
this.chamada.concat(alunos[i].getMatricula() + " / ");
this.chamada.concat(alunos[i].getNome() + " / ");
this.chamada.concat(alunos[i].getCurso() + "/n");
}
}
public void printChamada(){
System.out.println(chamada);
}
} }

View file

@ -1,40 +1,12 @@
import java.util.Scanner;
public class Gerenciador { public class Gerenciador {
private Dados dados; private Dados dados;
private static Scanner input = new Scanner(System.in);
String nome, local, curso, matricula, projeto, orientador;
int idade, semestre, ano;
boolean bolsista;
public Gerenciador(Dados dados) { public Gerenciador(Dados dados) {
this.dados = dados; this.dados = dados;
} }
public void cadastrarAluno() { public void cadastrarAluno() {
System.out.println("Insira o nome do aluno:");
nome = input.nextLine();
System.out.println("Insira o local de nascimento do aluno:");
local = input.nextLine();
System.out.println("Insira o curso do aluno:");
curso = input.nextLine();
System.out.println("Insira a matricula do aluno:");
matricula = input.nextLine();
System.out.println("Insira a idade do aluno:");
idade = input.nextInt();
System.out.println("Insira o semestre do aluno:");
semestre = input.nextInt();
System.out.println("Insira o ano do aluno:");
ano = input.nextInt();
Aluno aluno = new Aluno(nome, idade, local, curso, matricula, semestre, ano, bolsista); // Adicionar opção de bolsista
this.dados.appendAluno(aluno);
} }
public void cadastrarBolsista() { public void cadastrarBolsista() {
@ -45,19 +17,18 @@ public class Gerenciador {
} }
public void listarAlunos() { public void listarAlunos() {
this.dados.listAlunos();
} }
public void listarBolsistas() { public void listarBolsistas() {
this.dados.listBolsistas();
} }
public void maiorNome(){ public void maiorNome() {
this.dados.maiorNome();
} }
public void vogaisNomes(){ public void vogaisNomes() {
System.out.println("Numero total de vogais: " + this.dados.totalVowels());
} }
public void percentualAlunos() { public void percentualAlunos() {
@ -65,15 +36,14 @@ public class Gerenciador {
} }
public void mediaIdadeAlunos() { public void mediaIdadeAlunos() {
System.out.println("Idade média dos alunos: " + this.dados.averageAge());
} }
public void criarChamada() { public void criarChamada() {
this.dados.makeChamada();
} }
public void chamada() { public void chamada() {
this.dados.printChamada();
} }
public void calcularRisco() { public void calcularRisco() {

View file

@ -7,12 +7,12 @@ public class Menu {
private static Dados dados; private static Dados dados;
private static Gerenciador gerenciador; private static Gerenciador gerenciador;
private static Scanner input = new Scanner(System.in);
public static void main(String[] args) { public static void main(String[] args) {
dados = new Dados(); dados = new Dados();
gerenciador = new Gerenciador(dados); gerenciador = new Gerenciador(dados);
Scanner input = new Scanner(System.in);
while (true) { while (true) {
System.out.println( System.out.println(
"Escolha uma opcao:" + "\n" + "Escolha uma opcao:" + "\n" +
@ -37,8 +37,13 @@ public class Menu {
} }
public static void prompt(int option) { public static void prompt(int option) {
switch (option) { switch (option) {
// passar parametros
// String nome,int idade,String local, String curso, String matricula,int
// semestre,int ano ,bool bolsista, String projeto, String orientador
case 1: case 1:
gerenciador.cadastrarAluno(); // completar com o nome correto das gerenciadores gerenciador.cadastrarAluno(); // completar com o nome correto das gerenciadores
break; break;

View file

@ -1,15 +1,15 @@
public class Pessoa{ public class Pessoa{
private String nome; private int nome;
private int idade; private int idade;
private String localNascimento; private String localNascimento;
public Pessoa(String nome, int idade, String localNascimento){ public Pessoa(int nome, int idade, String localNascimento){
this.nome = nome; this.nome = nome;
this.idade = idade; this.idade = idade;
this.localNascimento = localNascimento; this.localNascimento = localNascimento;
} }
public String getNome(){ public int getNome(){
return this.nome; return this.nome;
} }