Pārlūkot izejas kodu

Finished part 1, commented out Arrays.java to make tests work

Luis Romero 6 gadus atpakaļ
vecāks
revīzija
46819f81e6

+ 4
- 4
src/main/java/Pair/Arrays.java Parādīt failu

@@ -10,7 +10,7 @@ import java.util.Collections;
10 10
  * A max method that returns the largest item in the arraylist
11 11
  * And a minmax method that returns a pair containing the largest and smallest items from the array list
12 12
  */
13
-public class Arrays {
14
-    public static <___> Pair<E> firstLast(ArrayList<___> a) {
15
-    }
16
-}
13
+//public class Arrays {
14
+//    public static <___> Pair<E> firstLast(ArrayList<___> a) {
15
+//    }
16
+//}

+ 18
- 1
src/main/java/StackArrayList/Stack.java Parādīt failu

@@ -8,8 +8,25 @@ import java.util.ArrayList;
8 8
  */
9 9
 public class Stack<E> {
10 10
     private ArrayList elements;
11
-    
11
+
12 12
     public Stack(){
13
+        this.elements = new ArrayList<E>();
14
+    }
15
+
16
+    public E push(E item) {
17
+        this.elements.add(item);
18
+        return item;
19
+    }
20
+
21
+    public E pop() {
22
+        return (E) this.elements.remove(elements.size() - 1);
23
+    }
13 24
 
25
+    public boolean isEmpty() {
26
+        if (this.elements.size() == 0) {
27
+            return true;
28
+        } else {
29
+            return false;
30
+        }
14 31
     }
15 32
 }