exo2: make the class methods more inline with the List<?> interface.
[Project_POO.git] / exo2 / ListExtension.java
index 3ba71ac607d993661cb26597093ae35c668ce024..a015be584fac6be368afe04642437fefb587fd49 100644 (file)
@@ -32,28 +32,32 @@ public class ListExtension<E> {
         return list.add(e);
     }
 
+    public int size() {
+        return list.size();
+    }
+
     /**
      * Should mimic the List<E> add(int index, T value) method
      * @param  value [description]
      * @return       [description]
      */
-    public void addMiddleIter(E value) {
-        int mid = list.size() / 2;
+    public void addIter(int index, E value) {
         ListIterator<E> iter = list.listIterator();
         int i = 0;
-        // go to the element at mid + 1 index
-        while (iter.hasNext() && i <= mid) {
+        // go to the element at index + 1
+        while (iter.hasNext() && i <= index) {
             iter.next();
             i++;
         }
         iter.add(value);
     }
 
-    public void addNEMiddle(int Nelements) {
+    //FIXME: replace parameter by the list of objects to add
+    public void addNelements(int index, int Nelements) {
         ListIterator<E> iter = list.listIterator();
         int i = 0;
-        // go to the element at the middle + 1 index
-        while (iter.hasNext() && i <= list.size() / 2) {
+        // go to the element at index + 1
+        while (iter.hasNext() && i <= index) {
             iter.next();
             i++;
         }