tout marche sauf le dernier
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
MonBrinIterator
|
||||
|
||||
gère la navigation dans un Brin d'ADN
|
||||
|
||||
*/
|
||||
|
||||
public class MonBrinIterator implements Iterator<Base> {
|
||||
private final MonBrin brin;
|
||||
private int currentIndex;
|
||||
|
||||
public MonBrinIterator(MonBrin brin) {
|
||||
this.brin = brin;
|
||||
this.currentIndex = 0; // Initialise l'index à 0 pour commencer depuis le début
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return currentIndex < brin.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base next() {
|
||||
if (!hasNext()) {
|
||||
throw new NoSuchElementException("Plus de bases dans le brin");
|
||||
}
|
||||
return brin.getBase(currentIndex++);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user