daniman

Atendente.class

Nov 24th, 2011
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.63 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package listaMetodosEstaticos;
  6.  
  7. import java.util.*;
  8.  
  9. /**
  10.  *
  11.  * @author sei
  12.  */
  13. public class Atendente {
  14.  
  15.     //Declarando as variáveis de instância
  16.     private String nome, curso;
  17.     ArrayList<Aluno> lista = new ArrayList<Aluno>();
  18.     private static int matricula = 20020240;
  19.  
  20.     //Inicializando o construtor da classe
  21.     public Atendente(String nome, String curso) {
  22.         this.nome = nome;
  23.         this.curso = curso;
  24.     }
  25.  
  26.     public String getCurso() {
  27.         return curso;
  28.     }
  29.  
  30.     public static int getMatricula() {
  31.         return matricula;
  32.     }
  33.  
  34.     public String getNome() {
  35.         return nome;
  36.     }
  37.  
  38.     public ArrayList<Aluno> getVetor() {
  39.         return lista;
  40.     }
  41.  
  42.     public void setCurso(String curso) {
  43.         this.curso = curso;
  44.     }
  45.  
  46.     public static void setMatricula(int matricula) {
  47.         Atendente.matricula = matricula;
  48.     }
  49.  
  50.     public void setNome(String nome) {
  51.         this.nome = nome;
  52.     }
  53.  
  54.     public void setVetor(ArrayList<Aluno> vetor) {
  55.         this.lista = vetor;
  56.     }
  57.  
  58.     public void inserirAluno(String nome, String curso) {
  59.  
  60.         Aluno atual;
  61.         int i = Atendente.matricula++;
  62.  
  63.         atual = new Aluno(nome, curso, i);
  64.         lista.add(atual);
  65.  
  66.     }
  67.  
  68.     public void imprimir() {
  69.  
  70.         for (int i = 0; i < lista.size(); i++) {
  71.             Aluno cc = (Aluno) lista.get(i);
  72.             System.out.println(cc.getNome());
  73.             System.out.println(cc.getCurso());
  74.             System.out.println(cc.getMatrícula());
  75.             System.out.println("############################################");
  76.         }
  77.  
  78.  
  79.     }
  80.  
  81.     public static void main(String[] args) {
  82.  
  83.         String nome, curso, nomeAluno, cursoAluno;
  84.  
  85.         Scanner teclado = new Scanner(System.in);
  86.         Atendente atendente;
  87.  
  88.         System.out.println("Informe o nome e o curso");
  89.         nome = teclado.nextLine();
  90.         curso = teclado.nextLine();
  91.  
  92.         //Chamando o construtor de atendente
  93.  
  94.         atendente = new Atendente(nome, curso);
  95.  
  96.         System.out.println("Informe o nome do aluno");
  97.         nomeAluno = teclado.nextLine();
  98.         cursoAluno = teclado.nextLine();
  99.  
  100.         atendente.inserirAluno(nomeAluno, cursoAluno);
  101.         atendente.inserirAluno("Maurício", "História");
  102.         atendente.inserirAluno("Hector Bruno ", "Engenharia elétrica");
  103.         atendente.inserirAluno("Guma", "Jornalista");
  104.         atendente.inserirAluno("Franceli", "Administradora");
  105.  
  106.  
  107.  
  108.         atendente.imprimir();
  109.  
  110.  
  111.     }
  112. }
  113.  
  114.  
Advertisement
Add Comment
Please, Sign In to add comment