//GRUPO 3 public class IteratorOeuvresArtistYear { private String name; private int year, currentOeuvre; private Oeuvre[] works; /* Dados um vector de objectos do tipo Oeuvre (totalmente ocupado, possivelmente * desordenado e possivelmente com obras de varios artistas), o nome dum artista * e um ano, constroi um iterador que da’ acesso ‘as obras do artista com o nome * dado que tenham sido concebidas no ano referido (se existir alguma). * * @pre works != null && name != null */ public IteratorOeuvresArtistYear(Oeuvre[] works, String name, int year) { this.works = works; this.name = name; this.year = year; currentOeuvre = 0; moveToNext(); } // @return true, se ainda ha’ alguma obra a devolver; false, no caso contrario. public boolean hasNext() { return works.length > currentOeuvre; } // @pre hasNext() public Oeuvre next() { Oeuvre toReturn = works[currentOeuvre++]; moveToNext(); return toReturn; } //Metodos auxiliares private void moveToNext() { while(hasNext() && works[currentOeuvre].getName() != name && works[currentOeuvre].getYear() != year) currentOeuvre++; } }