diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..1f58a0f
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+generics
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..fa6e49d
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 0000000..0dd4b35
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml
new file mode 100644
index 0000000..d411041
--- /dev/null
+++ b/.idea/libraries/Maven__junit_junit_4_12.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
new file mode 100644
index 0000000..f58bbc1
--- /dev/null
+++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..dc02d2a
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..ca63f44
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..e96534f
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..0cea312
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,1080 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+ true
+ true
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $USER_HOME$/.subversion
+
+
+
+
+ 1520539317479
+
+
+ 1520539317479
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No facets are configured
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+ generics
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+ Maven: junit:junit:4.12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 6f607c0..c566681 100644
--- a/README.md
+++ b/README.md
@@ -14,26 +14,26 @@ As always, you are required to produce UML and unit tests as well as your code t
### Part 1:
-Implement your own version of an ArrayList (we'll call it MyArrayList), with the following features:
+Implement your own version of an ArrayList (we'll call it io.generics.myArrayList.MyArrayList), with the following features:
-- MyArrayList must be a generic type, which can store any other type of object
-- MyArrayList must not use List, ArrayList or any other collection type in its implementation, only Arrays (The purpose of this is to practice designing your own generic class from the ground up, so that you can appreciate their complexities and usefulness)
-- MyArrayList must have `add()`, `get()`, `remove()`, `set()`, `clear()`, `isEmpty()`, `contains()` and other methods to provide the same basic functionality described in the [ArrayList documentation](https://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html)
+- io.generics.myArrayList.MyArrayList must be a generic type, which can store any other type of object
+- io.generics.myArrayList.MyArrayList must not use List, ArrayList or any other collection type in its implementation, only Arrays (The purpose of this is to practice designing your own generic class from the ground up, so that you can appreciate their complexities and usefulness)
+- io.generics.myArrayList.MyArrayList must have `add()`, `get()`, `remove()`, `set()`, `clear()`, `isEmpty()`, `contains()` and other methods to provide the same basic functionality described in the [ArrayList documentation](https://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html)
- `add()` should be overridden to add an element to the end of the Array, or to add the element to a specified index in the array.
-- MyArrayList must have a no-argument constructor (`MyArrayList()`) to initialize a new instance, it should also have a one-argument constructor (`MyArrayList(int)`) that takes an int and starts the list off at the specified size.
-- MyArrayList should automatically resize and maintain its order.
+- io.generics.myArrayList.MyArrayList must have a no-argument constructor (`io.generics.myArrayList.MyArrayList()`) to initialize a new instance, it should also have a one-argument constructor (`io.generics.myArrayList.MyArrayList(int)`) that takes an int and starts the list off at the specified size.
+- io.generics.myArrayList.MyArrayList should automatically resize and maintain its order.
### Part 2:
-Implement your own version of a Set (let's call it MySet ... seeing a pattern here?), with the following features:
+Implement your own version of a Set (let's call it io.generics.myArrayList.MySet ... seeing a pattern here?), with the following features:
-- MySet must be a generic type, which can store any other type of object
-- An instance of MySet must contain no duplicates
-- MySet must not use List, ArrayList, or any other built-in collection types in its implementation. You may use Arrays, and you may use your implementation of MyArrayList (if it helps -- you don't have to use it)
-- MySet must have all of the methods listed on the [Java Set documentation](https://docs.oracle.com/javase/7/docs/api/java/util/Set.html)
+- io.generics.myArrayList.MySet must be a generic type, which can store any other type of object
+- An instance of io.generics.myArrayList.MySet must contain no duplicates
+- io.generics.myArrayList.MySet must not use List, ArrayList, or any other built-in collection types in its implementation. You may use Arrays, and you may use your implementation of io.generics.myArrayList.MyArrayList (if it helps -- you don't have to use it)
+- io.generics.myArrayList.MySet must have all of the methods listed on the [Java Set documentation](https://docs.oracle.com/javase/7/docs/api/java/util/Set.html)
### Part 3 (Challenge):
-Implement your own version of a Map (MyMap) as a generic type that can map any key type to any value type.
+Implement your own version of a Map (io.generics.myArrayList.MyMap) as a generic type that can map any key type to any value type.
-MyMap should implement all of the methods and behavior described in the [Java Map documentation](https://docs.oracle.com/javase/7/docs/api/java/util/Map.html).
+io.generics.myArrayList.MyMap should implement all of the methods and behavior described in the [Java Map documentation](https://docs.oracle.com/javase/7/docs/api/java/util/Map.html).
diff --git a/generics.iml b/generics.iml
new file mode 100644
index 0000000..ea9ab4f
--- /dev/null
+++ b/generics.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 73be9cd..4e601ff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,8 +13,8 @@
org.apache.maven.plugins
maven-compiler-plugin
- 1.7
- 1.7
+ 1.8
+ 1.8
diff --git a/src/main/java/.deleteme b/src/main/java/.deleteme
deleted file mode 100644
index e69de29..0000000
diff --git a/src/main/java/io/generics/myArrayList/Collections.java b/src/main/java/io/generics/myArrayList/Collections.java
new file mode 100644
index 0000000..16c89ba
--- /dev/null
+++ b/src/main/java/io/generics/myArrayList/Collections.java
@@ -0,0 +1,16 @@
+package io.generics.myArrayList;
+
+public interface Collections {
+ boolean add(T value);
+ boolean addAll(T[] toBeAdded);
+ void clear();
+ boolean contains(T object);
+ boolean containsAll(T[] array);
+ boolean isEmpty();
+ boolean remove(T object);
+ boolean removeAll(T[] array);
+ boolean retainAll(T[] array);
+ int size();
+ Object[] toArray();
+
+}
diff --git a/src/main/java/io/generics/myArrayList/KeyValuePair.java b/src/main/java/io/generics/myArrayList/KeyValuePair.java
new file mode 100644
index 0000000..f3e7705
--- /dev/null
+++ b/src/main/java/io/generics/myArrayList/KeyValuePair.java
@@ -0,0 +1,50 @@
+package io.generics.myArrayList;
+
+public class KeyValuePair {
+
+
+ protected K key;
+ protected V value;
+
+
+ public KeyValuePair(K key, V value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public KeyValuePair(){
+ this.setValue(value);
+ this.setKey(key);
+
+ }
+
+ public void setKey(K key) {
+ this.key = key;
+ }
+
+ public void setValue(V value) {
+ this.value = value;
+ }
+
+ public K getKey() {
+ this.setKey(key);
+ return key;
+ }
+
+ public V getValue() {
+ this.setValue(value);
+ return value;
+ }
+
+ public boolean equalTo(K key){
+ if(getKey().equals(key)){
+ return true;
+ }
+ return false;
+ }
+
+ public void replace(V value1){
+ this.value = value1;
+ }
+
+}
diff --git a/src/main/java/io/generics/myArrayList/MyArrayList.java b/src/main/java/io/generics/myArrayList/MyArrayList.java
new file mode 100644
index 0000000..498de60
--- /dev/null
+++ b/src/main/java/io/generics/myArrayList/MyArrayList.java
@@ -0,0 +1,276 @@
+package io.generics.myArrayList;
+
+import java.util.Arrays;
+import java.lang.*;
+
+
+public class MyArrayList implements Collections {
+
+ private T[] myArrayList;
+
+
+ public MyArrayList(int size) {
+ this.myArrayList = (T[]) new Object[size];
+ }
+
+ public MyArrayList(T[] myArrayList) {
+ this.myArrayList = myArrayList;
+ }
+
+ public MyArrayList() {
+ this.myArrayList = (T[]) new Object[0];
+
+ }
+
+
+ public T[] toMyArray() {
+ return this.myArrayList;
+ }
+
+ @Override
+ public boolean add(T toBeAdded) {
+ myArrayList = Arrays.copyOf(myArrayList, myArrayList.length + 1);
+ myArrayList[myArrayList.length - 1] = toBeAdded;
+ return true;
+ }
+
+
+ public boolean addAt(int index, T toBeAdded) {
+ myArrayList = Arrays.copyOf(myArrayList, myArrayList.length + 1);
+ if (myArrayList.length == 1) {
+ myArrayList[0] = toBeAdded;
+ } else {
+ T[] temp = Arrays.copyOf(myArrayList, myArrayList.length);
+ for (int i = 0; i < myArrayList.length; i++) {
+ if(i index) {
+ temp[i] = myArrayList[i - 1];
+ } else if (i == index) {
+ temp[i] = toBeAdded;
+ }
+ }
+ myArrayList = Arrays.copyOf(temp, temp.length);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean addAll(T[] toBeAdded) {
+ int x = toBeAdded.length;
+ int y = myArrayList.length;
+ int counter = 0;
+ myArrayList = Arrays.copyOf(myArrayList, myArrayList.length + x);
+ for (int i = y; i < myArrayList.length; i++) {
+ myArrayList[i] = toBeAdded[counter];
+ counter++;
+ }
+ return true;
+ }
+
+ public boolean addAll(int index, T[] toBeAdded){
+ T[] tempArray = Arrays.copyOf(myArrayList, myArrayList.length + toBeAdded.length);
+ int x = 0;
+ for(int i = 0; i= index){
+ tempArray[i] = toBeAdded[x];
+ tempArray[myArrayList.length+x] = myArrayList[i];
+ x++;
+ }
+ }
+ myArrayList = Arrays.copyOf(tempArray, tempArray.length);
+ return true;
+ }
+
+ @Override
+ public void clear() {
+ myArrayList = Arrays.copyOf(myArrayList, 0);
+ }
+
+ @Override
+ public boolean contains(T value) {
+ for (T val : myArrayList) {
+ if (val.equals(value)) return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean containsAll(T[] array) {
+ for(int i = 0; i0) return false;
+ }
+ return true;
+ }
+
+ public T get(int index) {
+ T temp = myArrayList[0];
+ for (int i = 0; i < myArrayList.length; i++) {
+ if (i == index) {
+ temp = myArrayList[i];
+ }
+ }
+ return temp;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ if (myArrayList.length == 0) return true;
+ return false;
+ }
+
+ public int indexOf(T value){
+ Integer x = null;
+ for(int i = 0; i=0; i--){
+ if(myArrayList[i].equals(value)){
+ x=i;
+ break;
+ }
+ }
+ return x;
+ }
+
+ public boolean remove(int index) {
+ for (int i = 0; i < myArrayList.length; i++) {
+ if (i >= index) {
+ if (i == myArrayList.length - 1) {
+ myArrayList[i] = null;
+ } else {
+ myArrayList[i] = myArrayList[i + 1];
+ }
+ }
+ }
+ myArrayList = Arrays.copyOf(myArrayList, myArrayList.length - 1);
+ return true;
+ }
+
+ @Override
+ public boolean remove(T object){
+ int x = -1;
+ for(int i = 0; i< myArrayList.length; i++){
+ if(myArrayList[i].equals(object)){
+ myArrayList[i] = myArrayList[i+1];
+ x = i;
+ }
+ if(x !=-1 && i>x && i= 0) {
+ myArrayList = Arrays.copyOf(myArrayList, myArrayList.length - 1);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean removeAll(T[] objects) {
+
+//not working yet
+// for(int j = 0; j 0) {
+// myArrayList = Arrays.copyOf(myArrayList, myArrayList.length - objects.length);
+// return true;
+// }
+ return false;
+ }
+
+
+ public void replace(int index, T valueReplacing){
+ myArrayList[index] = valueReplacing;
+ }
+
+ @Override
+ public boolean retainAll(T[]objects){
+ T[] tempArray = Arrays.copyOf(myArrayList, myArrayList.length);
+ int x = 0;
+ for(int i = 0; i {
+
+ private KeyValuePair pair;
+ private MyArrayList> myMap;
+
+
+ public MyMap(){
+ this.myMap = new MyArrayList<>(16);
+ }
+
+ public MyMap(int size){
+ this.myMap = new MyArrayList<>(size);
+ }
+
+ public MyMap(MyArrayList> myMap1){
+ this.myMap = myMap1;
+ for(int i = 0; i 1){
+ myMap.remove(i);
+ }
+ }
+ }
+
+ public void setMyMap(MyArrayList> myMap1) {
+
+ }
+
+ public MyArrayList> getMyMap() {
+ return myMap;
+ }
+
+ public void clear(){
+ myMap.clear();
+ }
+
+ public boolean containsKey(K key){
+ for(int i = 0; i> entrySet(){
+ return null;
+ }
+
+ public V get(K key){
+ V val = null;
+ for(int i=0; i keySet(){
+ MyArrayList keyList = new MyArrayList<>();
+ for(int i = 0; i keys = new MySet<>(keyList);
+ return keys;
+ }
+
+ public boolean put(KeyValuePair value) {
+ myMap.add(value);
+ for (int i = 0; i < myMap.size(); i++) {
+ int x = 0;
+ for(int j = 0; j 1){
+ myMap.remove(i);
+ }
+ }
+ return true;
+ }
+
+ public boolean putAll(MyArrayList> arrayList){
+ myMap.addAll(arrayList.toMyArray());
+ for (int i = 0; i < myMap.size(); i++) {
+ int count = 0;
+ int x = 0;
+ for(int j = 0; j 1){
+ myMap.remove(i);
+ }
+ }
+ return true;
+ }
+
+ public void remove(int index){
+ myMap.remove(index);
+ }
+
+ public int size(){
+ return myMap.size();
+ }
+
+ public MyArrayList values(){
+ MyArrayList vals = new MyArrayList<>();
+ for(int i = 0; i implements Collections {
+
+ private MyArrayList mySet;
+
+ public MySet() {
+ this.mySet = new MyArrayList<>(16);
+ }
+
+ public MySet(int size) {
+ this.mySet = new MyArrayList<>(size);
+ }
+
+ public MySet(MyArrayList setInput) {
+ this.mySet = setInput;
+ for(int i = 0; i1){
+ setInput.remove(i);
+ }
+ }
+ this.mySet = setInput;
+ }
+
+ public void setMySet(MyArrayList setInput){
+ this.mySet = setInput;
+ for(int i = 0; i1){
+ setInput.remove(i);
+ }
+ }
+ this.mySet = setInput;
+ }
+
+ public MyArrayList getMySet() {
+ return mySet;
+ }
+
+ @Override
+ public boolean add(T value){
+ if(!mySet.contains(value)) {
+ mySet.add(value);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean addAll(T[] array){
+ mySet.addAll(array);
+ return true;
+ }
+
+ @Override
+ public void clear(){
+ mySet.clear();
+ }
+
+ @Override
+ public boolean contains(T value){
+ return mySet.contains(value);
+ }
+
+ @Override
+ public boolean containsAll(T[] array){
+ for(T object: array){
+ if(!mySet.contains(object)){
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean isEmpty(){
+ return mySet.isEmpty();
+ }
+
+ @Override
+ public boolean remove(T object){
+ if(mySet.contains(object)) {
+ mySet.remove(object);
+ return true;
+ }
+ return false;
+ }
+
+ public boolean removeAll(T[] array){
+ return true;
+ }
+
+ public boolean retainAll(T[] array){
+ mySet.retainAll(array);
+ return true;
+ }
+
+ public int size(){
+ return mySet.size();
+ }
+
+ public T[] toArray(){
+ return mySet.toMyArray();
+ }
+
+
+ public T set(int index, T object){
+ return mySet.set(index, object);
+ }
+
+ @Override
+ public String toString(){
+ return String.valueOf(mySet);
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/.deleteme b/src/test/java/.deleteme
deleted file mode 100644
index e69de29..0000000
diff --git a/src/test/java/io/generics/myArrayList/KeyValuePairTest.java b/src/test/java/io/generics/myArrayList/KeyValuePairTest.java
new file mode 100644
index 0000000..92b7382
--- /dev/null
+++ b/src/test/java/io/generics/myArrayList/KeyValuePairTest.java
@@ -0,0 +1,25 @@
+package io.generics.myArrayList;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class KeyValuePairTest {
+ @Test
+ public void constructorTest(){
+ KeyValuePair myPair = new KeyValuePair<>("Key", 5);
+ String expectedKey = "Key";
+ Integer expectedValue = 5;
+ String actualKey = myPair.getKey();
+ Integer actualValue = myPair.getValue();
+ Assert.assertEquals(expectedKey, actualKey);
+ Assert.assertEquals(expectedValue, actualValue);
+
+ }
+
+ @Test
+ public void equalsTest(){
+ KeyValuePair myPair = new KeyValuePair<>("Key", 5);
+ boolean actual = myPair.equalTo("Key");
+ Assert.assertTrue(actual);
+ }
+}
diff --git a/src/test/java/io/generics/myArrayList/MyArrayListTest.java b/src/test/java/io/generics/myArrayList/MyArrayListTest.java
new file mode 100644
index 0000000..5b310c5
--- /dev/null
+++ b/src/test/java/io/generics/myArrayList/MyArrayListTest.java
@@ -0,0 +1,233 @@
+package io.generics.myArrayList;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MyArrayListTest {
+
+ @Test
+ public void constructor1Test(){
+ MyArrayList array = new MyArrayList<>();
+ Assert.assertNotNull(array);
+ }
+
+ @Test
+ public void constructor2Test(){
+ MyArrayList array = new MyArrayList<>(3);
+ int expected = 3;
+ int actual = array.size();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void addTest(){
+ MyArrayList myArrayList = new MyArrayList<>(new String[]{"1", "2", "3", "4"});
+ String toBeAdded = "5";
+ String[] expected = {"1","2","3","4","5"};
+ myArrayList.add(toBeAdded);
+ String[] actual = myArrayList.toMyArray();
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+ @Test
+ public void add2Test(){
+ MyArrayList myArray = new MyArrayList<>(new Integer[]{1, 2, 4, 5});
+ Integer toBeAdded = 3;
+ Integer[] expected = {1, 2, 3, 4, 5};
+ myArray.addAt(2, toBeAdded);
+ Integer[] actual = myArray.toMyArray();
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+ @Test
+ public void addAllTest1(){
+ MyArrayList myArrayList = new MyArrayList<>(new Integer[]{1,2,3,4,5});
+ Integer[] toAdd = {6,7,8};
+ boolean x = myArrayList.addAll(toAdd);
+ Integer [] expected = {1,2,3,4,5,6,7,8};
+ Integer[] actual = myArrayList.toMyArray();
+
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+ @Test
+ public void addAllTest2(){
+ Integer[] input = {1,2,3,4,5};
+ MyArrayList id = new MyArrayList<>(input);
+ Integer[] toAdd = {6,7,8};
+ Integer[] expected = {1,2,6,7,8,3,4,5};
+ id.addAll(2, toAdd);
+ Integer[] actual = id.toMyArray();
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+ @Test
+ public void getTest(){
+ MyArrayList array = new MyArrayList<>(new Integer[]{1, 2, 3, 4, 5, 6});
+ Integer expected = 4;
+ Integer actual = array.get(3);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void removeByIndexTest(){
+ MyArrayList array = new MyArrayList<>(new Integer[]{1,2,3,4,5});
+ Integer[] expected = {1,2,3,5};
+ array.remove(3);
+ Integer[] actual = array.toMyArray();
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+ @Test
+ public void removeItemTest(){
+ MyArrayList arrayList = new MyArrayList<>(new String[]{"a","b","c","d","e","f"});
+ String[] expected = {"a","b","d","e","f"};
+ arrayList.remove("c");
+ String[] actual = arrayList.toMyArray();
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+ @Test
+ public void removeAllTest(){
+ MyArrayList arrayList = new MyArrayList<>(new String[]{"a","b","c","d","e","f","g","h"});
+ String[] expected = {"a","b","c","f"};
+ String[] toRemove = {"d","e","g","h"};
+ arrayList.removeAll(toRemove);
+ String[] actual = arrayList.toMyArray();
+ Assert.assertArrayEquals(expected,actual);
+ }
+
+
+ @Test
+ public void replaceTest(){
+ MyArrayList arrayList = new MyArrayList<>(new String[]{"a","b","c","d","e","f"});
+ String[] expected = {"a","b","c","c","e","f"};
+ arrayList.replace(3,"c");
+ String[] actual = arrayList.toMyArray();
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+
+ @Test
+ public void retainAllTest(){
+ MyArrayList arrayList = new MyArrayList<>(new Integer[]{1,2,2,3,4,5,6,7,8});
+ Integer[] expected = {2,2,4,6,8};
+ arrayList.retainAll(new Integer[]{2,4,6,8});
+ Integer[] actual = arrayList.toMyArray();
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+ @Test
+ public void retainAll2Test(){
+ String[] input= {"a","b","c","d","e","f"};
+ MyArrayList arrayList = new MyArrayList<>(input);
+ String[] expected = {"a","c","f"};
+ arrayList.retainAll(new String[]{"a","c","f"});
+ String[] actual = arrayList.toMyArray();
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+
+ @Test
+ public void clearTest(){
+ Integer[] input = {1,2,3,4,5};
+ MyArrayList array = new MyArrayList<>(input);
+ Integer[] expected = {};
+ array.clear();
+ Integer[] actual = array.toMyArray();
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+ @Test
+ public void setTest(){
+ Integer[] input = {1,2,3,4};
+ MyArrayList array = new MyArrayList<>(input);
+ Integer expected = 2;
+ Integer actual = array.set(1,10);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void setTest2() {
+ MyArrayList array = new MyArrayList<>(new Integer[]{1, 2, 3, 4});
+ Integer expected = 10;
+ array.set(1, 10);
+ Integer actual = array.get(1);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void containsTest(){
+ MyArrayList array = new MyArrayList<>(new Integer[]{1,2,3,4,5,6});
+ boolean actual = array.contains(4);
+ Assert.assertTrue(actual);
+ }
+
+ @Test
+ public void containsAllTest(){
+ MyArrayList array = new MyArrayList<>(new Integer[]{1,2,3,4,5,6});
+ boolean actual = array.containsAll(new Integer[]{2,4});
+ Assert.assertTrue(actual);
+ }
+
+ @Test
+ public void isEmptyTest(){
+ MyArrayList array = new MyArrayList<>(new String[]{});
+
+ Assert.assertTrue(array.isEmpty());
+ }
+
+ @Test
+ public void subListTest(){
+ MyArrayList array = new MyArrayList<>(new Integer[]{1,2,3,4,5,6,7});
+ Integer[] expected = {3,4,5};
+ Integer[] actual = array.subList(2, 5);
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+ @Test
+ public void sizeTest(){
+ Integer[] input = {1,2,3,4,5,6,7};
+ MyArrayList array = new MyArrayList<>(input);
+ int expected = 7;
+ int actual = array.size();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void indexOfTest(){
+ Integer[] input = {1,2,3,4,5,4,4};
+ MyArrayList array = new MyArrayList<>(input);
+ int expected = 3;
+ int actual = array.indexOf(4);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void lastIndexOfTest(){
+ Integer[] input = {1,2,3,4,5,4,4};
+ MyArrayList array = new MyArrayList<>(input);
+ int expected = 6;
+ int actual = array.lastIndexOf(4);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void toArrayTest1(){
+ Integer[] input = {1,2,3,4,5,6,7};
+ MyArrayList myArrayList = new MyArrayList<>(input);
+ Object[] expected = {1,2,3,4,5,6,7};
+ Object[] actual = myArrayList.toArray();
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+
+ @Test
+ public void countDupesTest(){
+ Integer[] input = {1,1,2,1,3,1,4,1,5,1,6,1,7};
+ MyArrayList array = new MyArrayList<>(input);
+ Integer expected = 7;
+ Integer actual = array.countDuplicates(0);
+ Assert.assertEquals(expected, actual);
+ }
+}
diff --git a/src/test/java/io/generics/myArrayList/MyMapTest.java b/src/test/java/io/generics/myArrayList/MyMapTest.java
new file mode 100644
index 0000000..bf91d34
--- /dev/null
+++ b/src/test/java/io/generics/myArrayList/MyMapTest.java
@@ -0,0 +1,164 @@
+package io.generics.myArrayList;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MyMapTest {
+
+ @Test
+ public void constructorTest(){
+ MyMap myMap = new MyMap<>();
+ int expected = 16;
+ int actual = myMap.getMyMap().size();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void constructor2Test(){
+ KeyValuePair kV1 = new KeyValuePair<>("Carolynn",100);
+ KeyValuePair kV2 = new KeyValuePair<>("Carolynn", 300);
+ KeyValuePair kV3 = new KeyValuePair<>("Luis", 400);
+ MyMap myMap = new MyMap<>(new MyArrayList<>(new KeyValuePair[]{kV1,kV2,kV3}));
+ KeyValuePair expected = kV2;
+ KeyValuePair actual = myMap.getMyMap().get(0);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void constructor3Test(){
+ KeyValuePair kV1 = new KeyValuePair<>("Key",100);
+ KeyValuePair kV2 = new KeyValuePair<>("Carolynn", 300);
+ KeyValuePair kV3 = new KeyValuePair<>("Luis", 400);
+ MyMap myMap = new MyMap<>(new MyArrayList<>(new KeyValuePair[]{kV1,kV2,kV3}));
+ int expected = 3;
+ int actual = myMap.size();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void putTest(){
+ KeyValuePair kV1 = new KeyValuePair<>("Key", 5);
+ KeyValuePair kV2 = new KeyValuePair<>("Carolynn", 100);
+ KeyValuePair kV3 = new KeyValuePair<>("Luis",100);
+ MyMap myMap = new MyMap<>(new MyArrayList<>(new KeyValuePair[]{kV1,kV2}));
+ myMap.put(kV3);
+ KeyValuePair expected = kV3;
+ KeyValuePair actual = myMap.getMyMap().get(2);
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void put2Test(){
+ KeyValuePair kV1 = new KeyValuePair<>("Key",5);
+ KeyValuePair kV2 = new KeyValuePair<>("Carolynn", 100);
+ KeyValuePair kV3 = new KeyValuePair<>("Carolynn", 200);
+ MyMap myMap = new MyMap<>(new MyArrayList<>(new KeyValuePair[]{kV1,kV2}));
+ myMap.put(kV3);
+ int actual = myMap.getMyMap().get(myMap.size()-1).getValue();
+ int expected = 200;
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void putAllTest() {
+ KeyValuePair kV1 = new KeyValuePair<>("Key", 5);
+ KeyValuePair kV2 = new KeyValuePair<>("Carolynn", 100);
+ KeyValuePair kV3 = new KeyValuePair<>("Luis", 100);
+ MyMap myMap1 = new MyMap<>(new MyArrayList<>(new KeyValuePair[]{kV1, kV2, kV3}));
+
+ KeyValuePair kV4 = new KeyValuePair<>("Sandra", 50);
+ KeyValuePair kV5 = new KeyValuePair<>("Andy", 75);
+ MyArrayList> myMap2 = new MyArrayList<>(new KeyValuePair[]{kV4,kV5,kV3});
+
+ myMap1.putAll(myMap2);
+ KeyValuePair[] expected = new KeyValuePair[]{kV1,kV2,kV4,kV5,kV3};
+ KeyValuePair [] actual = myMap1.getMyMap().toMyArray();
+ Assert.assertArrayEquals(expected,actual);
+ }
+
+
+
+ @Test
+ public void removeTest(){
+ KeyValuePair kV1 = new KeyValuePair<>("Key",5);
+ KeyValuePair kV2 = new KeyValuePair<>("Carolynn", 100);
+ KeyValuePair kV3 = new KeyValuePair<>("Luis",100);
+ MyMap myMap = new MyMap<>(new MyArrayList<>(new KeyValuePair[]{kV1,kV2, kV3}));
+ myMap.remove(myMap.size()-1);
+ String expected = "Carolynn";
+ String actual = myMap.getMyMap().get(myMap.size()-1).getKey();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void containsKeyTest(){
+ KeyValuePair kV1 = new KeyValuePair<>("Key",5);
+ KeyValuePair kV2 = new KeyValuePair<>("Carolynn", 100);
+ KeyValuePair kV3 = new KeyValuePair<>("Luis",100);
+ MyMap myMap = new MyMap<>(new MyArrayList<>(new KeyValuePair[]{kV1,kV2, kV3}));
+ Assert.assertTrue(myMap.containsKey("Key"));
+ }
+
+ @Test
+ public void containsValueTest(){
+ KeyValuePair kV1 = new KeyValuePair<>("Key",5);
+ KeyValuePair kV2 = new KeyValuePair<>("Carolynn", 100);
+ KeyValuePair kV3 = new KeyValuePair<>("Luis",200);
+ MyMap myMap = new MyMap<>(new MyArrayList<>(new KeyValuePair[]{kV1,kV2, kV3}));
+ Assert.assertTrue(myMap.containsValue(100));
+ }
+
+ @Test
+ public void isEmptyTest(){
+ MyMap myMap = new MyMap<>(new MyArrayList<>(new KeyValuePair[]{}));
+ Assert.assertTrue(myMap.isEmpty());
+ }
+
+ @Test
+ public void clearTest(){
+ KeyValuePair kV1 = new KeyValuePair<>("Key",5);
+ KeyValuePair kV2 = new KeyValuePair<>("Carolynn", 100);
+ KeyValuePair kV3 = new KeyValuePair<>("Luis",100);
+ MyMap myMap = new MyMap<>(new MyArrayList<>(new KeyValuePair[]{kV1,kV2, kV3}));
+ myMap.clear();
+ Assert.assertTrue(myMap.isEmpty());
+ }
+
+ @Test
+ public void getTest(){
+ KeyValuePair kV1 = new KeyValuePair<>("Key",5);
+ KeyValuePair kV2 = new KeyValuePair<>("Carolynn", 100);
+ KeyValuePair kV3 = new KeyValuePair<>("Luis",200);
+ MyMap myMap = new MyMap<>(new MyArrayList<>(new KeyValuePair[]{kV1,kV2, kV3}));
+ Integer actual = myMap.get("Luis");
+ Integer expected = 200;
+ Assert.assertEquals(expected,actual);
+
+ }
+
+ @Test
+ public void keySetTest(){
+ KeyValuePair kV1 = new KeyValuePair<>("Key",5);
+ KeyValuePair kV2 = new KeyValuePair<>("Carolynn", 100);
+ KeyValuePair kV3 = new KeyValuePair<>("Luis",200);
+ MyMap myMap = new MyMap<>(new MyArrayList<>(new KeyValuePair[]{kV1,kV2, kV3}));
+ String[] expected = {"Key","Carolynn","Luis"};
+ Object[] actual = myMap.keySet().getMySet().toMyArray();
+ Assert.assertArrayEquals(expected,actual);
+ }
+
+ @Test
+ public void valuesTest(){
+ KeyValuePair kV1 = new KeyValuePair<>("Key",5);
+ KeyValuePair kV2 = new KeyValuePair<>("Carolynn", 100);
+ KeyValuePair kV3 = new KeyValuePair<>("Luis",200);
+ MyMap myMap = new MyMap<>(new MyArrayList<>(new KeyValuePair[]{kV1,kV2, kV3}));
+ Integer[] expected = {5,100,200};
+ Object[] actual = myMap.values().toMyArray();
+ Assert.assertArrayEquals(expected,actual);
+ }
+
+
+
+
+}
diff --git a/src/test/java/io/generics/myArrayList/MySetTest.java b/src/test/java/io/generics/myArrayList/MySetTest.java
new file mode 100644
index 0000000..625d970
--- /dev/null
+++ b/src/test/java/io/generics/myArrayList/MySetTest.java
@@ -0,0 +1,134 @@
+package io.generics.myArrayList;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MySetTest {
+
+ @Test
+ public void constructorTest(){
+ String[] in = {"a","b","c","d","d"};
+ MyArrayList input = new MyArrayList<>(in);
+ MySet mySet = new MySet<>(input);
+ String[] expected = {"a","b","c","d"};
+ String[] actual = mySet.getMySet().toMyArray();
+
+ Assert.assertArrayEquals(expected, actual);
+ }
+ @Test
+ public void constructor2Test(){
+ MySet mySet = new MySet<>();
+ int expected = 16;
+ int actual = mySet.size();
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void constructor3Test(){
+ MySet mySet = new MySet<>(3);
+ int expected = 3;
+ int actual = mySet.size();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void addTest(){
+ Integer[] in = {1,2,3,4,6};
+ MyArrayList input = new MyArrayList<>(in);
+ MySet mySet = new MySet<>(input);
+ Integer toBeAdded = 6;
+ MyArrayList expected = input;
+ mySet.add(toBeAdded);
+ MyArrayList actual = mySet.getMySet();
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void addAllTest1(){
+ Integer[] input = {1,2,3,4,5};
+ MySet mySet = new MySet<>(new MyArrayList<>(input));
+ Integer[] toBeAdded = {6,7,8};
+ Integer[] expected = {1,2,3,4,5,6,7,8};
+ mySet.addAll(toBeAdded);
+ Integer[] actual = mySet.toArray();
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+ @Test
+ public void removeTest(){
+ String[] input = {"a","b","c","d","e"};
+ MySet mySet = new MySet<>(new MyArrayList<>(input));
+ mySet.remove("c");
+ String[] expected = {"a","b","d","e"};
+ String[] actual = mySet.toArray();
+ Assert.assertArrayEquals(expected,actual);
+ }
+
+ @Test
+ public void retainAll(){
+ Integer[] input = {1,2,3,4,5,6,7};
+ MySet mySet = new MySet<>(new MyArrayList<>(input));
+ Integer[] expected = {4,5,6,7};
+ mySet.retainAll(new Integer[]{4,5,6,7});
+ Integer[] actual = mySet.toArray();
+ Assert.assertArrayEquals(expected,actual);
+ }
+
+ @Test
+ public void sizeTest(){
+ MySet mySet = new MySet<>(new MyArrayList<>(new Integer[]{1,2,3,4,5}));
+ int expected = 5;
+ int actual = mySet.size();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void containsTest(){
+ Integer[] input = {1,2,3,4,5};
+ MyArrayList in = new MyArrayList<>(input);
+ MySet mySet = new MySet<>(in);
+ boolean actual = mySet.contains(3);
+ Assert.assertTrue(actual);
+ }
+
+ @Test
+ public void containsAll(){
+ Integer[] input = {1,2,3,4,5};
+ MyArrayList in = new MyArrayList<>(input);
+ MySet mySet = new MySet<>(in);
+
+ Assert.assertTrue(mySet.containsAll(new Integer[]{2,5}));
+ }
+
+ @Test
+ public void containsAll2(){
+ Integer[] input = {1,2,3,4,5};
+ MyArrayList in = new MyArrayList<>(input);
+ MySet mySet = new MySet<>(in);
+
+ Assert.assertFalse(mySet.containsAll(new Integer[]{5,7}));
+ }
+
+ @Test
+ public void isEmptyTest(){
+ Integer[] input = {};
+ MyArrayList in = new MyArrayList<>(input);
+ MySet mySet = new MySet<>(in);
+
+ Assert.assertTrue(mySet.isEmpty());
+ }
+
+ @Test
+ public void clearTest(){
+ MySet mySet = new MySet<>(new MyArrayList<>(new Integer[]{1,2,3,4,5}));
+ Integer[] expected = {};
+ mySet.clear();
+ Integer[] actual = mySet.toArray();
+
+ Assert.assertArrayEquals(expected, actual);
+ }
+
+
+}