update
This commit is contained in:
@@ -11,12 +11,14 @@ import java.util.NoSuchElementException;
|
||||
*/
|
||||
public class MonBrin implements Iterator<Base>{
|
||||
|
||||
private MonMaillon debut;
|
||||
|
||||
public MonBrin(MonMaillon p){
|
||||
throw new UnsupportedOperationException("cette méthode n'est pas implémentée");
|
||||
this.debut = p;
|
||||
}
|
||||
|
||||
public MonMaillon getDebut(){
|
||||
throw new UnsupportedOperationException("cette méthode n'est pas implémentée");
|
||||
return this.debut;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,18 +27,20 @@ public class MonBrin implements Iterator<Base>{
|
||||
// voir https://stackoverflow.com/questions/94361/when-do-you-use-javas-override-annotation-and-why
|
||||
@Override
|
||||
public boolean hasNext(){
|
||||
throw new UnsupportedOperationException("cette méthode n'est pas implémentée");
|
||||
if(this.debut != null){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base next() {
|
||||
throw new UnsupportedOperationException("cette méthode n'est pas implémentée");
|
||||
throw new NoSuchElementException();
|
||||
|
||||
//throw new NoSuchElementException("The iteration has no more elements ");
|
||||
if(hasNext()){
|
||||
Base b = this.debut.getBase();
|
||||
this.debut = this.debut.getSuiteMaillon();
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user