How to implement a TAD queue with complex objects?

0

I need to implement a data structure queue, with objects, being RA and student name but I am not able to evolve, a single row with integers I get good, this is not going to happen.

I think I'm picking up is in the main, I'm not sure how to call the methods or how to instantiate the classes.

Follow it as far as I can:

public class Aluno implements Comparable<Aluno> {

  private Integer RA;

  private String nome;

  public Aluno (Integer RA, String nome) {
    this.RA = RA;
    this.nome = nome;
  }

  public Integer getRA(){
    return this.RA;
  }

  public void setRA(Integer RA) {
    this.RA = RA;
  }

  public String getNome() {
    return this.nome;
  }

  public void setNome(String nome) {
    this.nome = nome;
  }

  @Override
  public String toString() {
    return this.RA+" - "+this.nome;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }
    if (!Aluno.class.isAssignableFrom(obj.getClass())) {
        return false;
    }
    final Aluno aluno = (Aluno) obj;
    return this.RA.equals(aluno.getRA());
  }

  @Override
  public int compareTo(Aluno o) {
    Integer compare = this.RA.compareTo(o.getRA());
    if(compare == 0){
      compare = this.nome.compareTo(o.getNome());
    }
    return compare;
  }

}

Row class

import java.util.List;
import java.util.Vector;

public class Fila {

  private List<Aluno> items = new LinkedList<Aluno>;

  public Fila() {
    this.items = new Vector<>();
  }

  public void enfilera(Aluno aluno) {
    this.items.add(Aluno);

  }

  public Aluno desenfilera() {
    return this.items.remove(0);
  }

  public boolean eVazio() {
    return this.items.size() == 0;
  }

  public int tamanho(){
    return 0;
  }

  public List<Aluno> getItems(){
    return this.items;
  }

}

Main:

class Main {
  public static void main(String[] args) {

    Fila fila = new Fila();

    Aluno aluno = new Aluno();
    fila.insere(aluno);

  }
}
    
asked by anonymous 12.05.2018 / 17:12

0 answers