diff --git a/DEV.3.4/TP/TP4/stub/0Bad/MonBrin.java b/DEV.3.4/TP/TP4/stub/0Bad/MonBrin.java
index c783ca7..b934173 100644
--- a/DEV.3.4/TP/TP4/stub/0Bad/MonBrin.java
+++ b/DEV.3.4/TP/TP4/stub/0Bad/MonBrin.java
@@ -7,30 +7,23 @@
Cette version a un problème : la navigation n'est pas raisonnable
*/
-public class MonBrin implements Iterator {
+public class MonBrin {
- private MonMaillon p;
private MonMaillon debut;
//Le constructeur fabrique un brin à partir du premier maillon p;
public MonBrin(MonMaillon p){
- this.p = p;
- MonMaillon s = new MonMaillon(Base.G/*, null*/);
- s = MonMaillon(Base.A, s);
- s = MonMaillon(Base.T, s);
- s = MonMaillon(Base.T, s);
- s = MonMaillon(Base.C, s);
- s = MonMaillon(Base.G, s);
+ this.debut = p;
}
public MonMaillon getDebut(){
- return debut;
+ return this.debut;
}
/** et pour naviguer?
On pourrait implémenter l'interface iterator de java.util ici
**/
- public
+
}
diff --git a/DEV.3.4/TP/TP4/stub/1Iterable/MonBrin.java b/DEV.3.4/TP/TP4/stub/1Iterable/MonBrin.java
index 473e131..ae29f93 100644
--- a/DEV.3.4/TP/TP4/stub/1Iterable/MonBrin.java
+++ b/DEV.3.4/TP/TP4/stub/1Iterable/MonBrin.java
@@ -11,12 +11,14 @@ import java.util.NoSuchElementException;
*/
public class MonBrin implements Iterator{
+ 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{
// 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;
+ }
}
-
-}
-
-
-
-
+}
\ No newline at end of file
diff --git a/DEV.3.4/TP/TP4/stub/1Iterable/MonMaillon.java b/DEV.3.4/TP/TP4/stub/1Iterable/MonMaillon.java
index 6f93fe5..f4e0c49 100644
--- a/DEV.3.4/TP/TP4/stub/1Iterable/MonMaillon.java
+++ b/DEV.3.4/TP/TP4/stub/1Iterable/MonMaillon.java
@@ -6,21 +6,24 @@
*/
public class MonMaillon {
+ private MonMaillon suivant;
+ private Base contenu;
public MonMaillon(Base b){
- throw new UnsupportedOperationException("cette méthode n'est pas implémentée");
+ this.contenu = b;
}
public MonMaillon(Base b, MonMaillon l){
- throw new UnsupportedOperationException("cette méthode n'est pas implémentée");
+ this.contenu = b;
+ this.suivant = l;
}
public Base getBase(){
- throw new UnsupportedOperationException("cette méthode n'est pas implémentée");
+ return this.contenu;
}
public MonMaillon getSuiteMaillon(){
- throw new UnsupportedOperationException("cette méthode n'est pas implémentée");
+ return this.suivant;
}
}