gerenciador-rev
This commit is contained in:
parent
0aba824e8c
commit
85aabf555e
6 changed files with 139 additions and 21 deletions
|
|
@ -6,7 +6,7 @@ public class Aluno {
|
|||
private int ano;
|
||||
private boolean bolsista;
|
||||
|
||||
public Aluno(int nome, int idade, String localNascimento, String curso, String matricula, int semestre, int ano, boolean bolsista){
|
||||
public Aluno(String nome, int idade, String localNascimento, String curso, String matricula, int semestre, int ano, boolean bolsista){
|
||||
this.pessoa = new Pessoa(nome, idade, localNascimento);
|
||||
this.curso = curso;
|
||||
this.matricula = matricula;
|
||||
|
|
@ -15,7 +15,7 @@ public class Aluno {
|
|||
this.bolsista = bolsista;
|
||||
}
|
||||
|
||||
public int getNome(){
|
||||
public String getNome(){
|
||||
return this.pessoa.getNome();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ public class Bolsista{
|
|||
private String projeto;
|
||||
private String orientador;
|
||||
|
||||
public Bolsista(int nome, int idade, String localNascimento, String curso, String matricula, int semestre, int ano, boolean bolsista, String projeto, String orientador){
|
||||
public Bolsista(String 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.projeto = projeto;
|
||||
this.orientador = orientador;
|
||||
}
|
||||
|
||||
public int getNome(){
|
||||
public String getNome(){
|
||||
return this.aluno.getNome();
|
||||
}
|
||||
|
||||
|
|
|
|||
93
Dados.java
93
Dados.java
|
|
@ -1,2 +1,95 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,40 @@
|
|||
import java.util.Scanner;
|
||||
|
||||
public class Gerenciador {
|
||||
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) {
|
||||
this.dados = dados;
|
||||
}
|
||||
|
||||
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() {
|
||||
|
|
@ -17,18 +45,19 @@ public class Gerenciador {
|
|||
}
|
||||
|
||||
public void listarAlunos() {
|
||||
|
||||
this.dados.listAlunos();
|
||||
}
|
||||
|
||||
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() {
|
||||
|
|
@ -36,14 +65,15 @@ public class Gerenciador {
|
|||
}
|
||||
|
||||
public void mediaIdadeAlunos() {
|
||||
System.out.println("Idade média dos alunos: " + this.dados.averageAge());
|
||||
}
|
||||
|
||||
public void criarChamada() {
|
||||
|
||||
this.dados.makeChamada();
|
||||
}
|
||||
|
||||
public void chamada() {
|
||||
|
||||
this.dados.printChamada();
|
||||
}
|
||||
|
||||
public void calcularRisco() {
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ public class Menu {
|
|||
|
||||
private static Dados dados;
|
||||
private static Gerenciador gerenciador;
|
||||
private static Scanner input = new Scanner(System.in);
|
||||
|
||||
public static void main(String[] args) {
|
||||
dados = new Dados();
|
||||
gerenciador = new Gerenciador(dados);
|
||||
|
||||
Scanner input = new Scanner(System.in);
|
||||
while (true) {
|
||||
System.out.println(
|
||||
"Escolha uma opcao:" + "\n" +
|
||||
|
|
@ -37,13 +37,8 @@ public class Menu {
|
|||
}
|
||||
|
||||
public static void prompt(int 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:
|
||||
gerenciador.cadastrarAluno(); // completar com o nome correto das gerenciadores
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
public class Pessoa{
|
||||
private int nome;
|
||||
private String nome;
|
||||
private int idade;
|
||||
private String localNascimento;
|
||||
|
||||
public Pessoa(int nome, int idade, String localNascimento){
|
||||
public Pessoa(String nome, int idade, String localNascimento){
|
||||
this.nome = nome;
|
||||
this.idade = idade;
|
||||
this.localNascimento = localNascimento;
|
||||
}
|
||||
|
||||
public int getNome(){
|
||||
public String getNome(){
|
||||
return this.nome;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue