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..c20d346
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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..d30d09e
--- /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/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..e9a74e1
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,784 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ trim
+ equals
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1520539100206
+
+
+ 1520539100206
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/generics.iml b/generics.iml
new file mode 100644
index 0000000..9717c26
--- /dev/null
+++ b/generics.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
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/Mapping.java b/src/main/java/Mapping.java
new file mode 100644
index 0000000..8e1aa87
--- /dev/null
+++ b/src/main/java/Mapping.java
@@ -0,0 +1,45 @@
+import java.util.Objects;
+
+public class Mapping {
+
+ K key;
+ V value;
+
+ public Mapping(K key, V value){
+ this.key = key;
+ this.value = value;
+
+ }
+
+ public V getValue(){
+ return this.value;
+ }
+
+ public K getKey(){
+ return this.key;
+ }
+
+ public void setValue(V newValue){
+ this.value = newValue;
+
+ }
+
+ @Override
+ public boolean equals(Object o){
+ if(o==this)return true;
+ if(!(o instanceof Mapping))return false;
+
+ Mapping m = (Mapping) o;
+ return this.key.equals(m.key);
+
+ }
+
+ /*@Override
+ public int hashCode(){
+ return Objects.hash(key,value);
+ }*/
+
+
+
+
+}
diff --git a/src/main/java/MyArrayList.java b/src/main/java/MyArrayList.java
new file mode 100644
index 0000000..62a2723
--- /dev/null
+++ b/src/main/java/MyArrayList.java
@@ -0,0 +1,245 @@
+
+
+import java.util.Arrays;
+
+@SuppressWarnings("unchecked")
+public class MyArrayList {
+
+
+
+ private T[] myArray;
+ private int numberOfObjects;
+
+
+
+ public MyArrayList(){
+ this.myArray = (T[]) new Object[0];
+
+ }
+
+ public MyArrayList(int capacity){
+ this.myArray = (T[]) new Object[capacity];
+
+ }
+
+ public void add(T element){
+ if(this.contains(null)){
+ this.set(this.indexOf(null), element);
+ }
+ else{
+ this.myArray = Arrays.copyOf(myArray, myArray.length+1);
+ this.myArray[this.myArray.length-1] = element;
+ }
+ this.numberOfObjects++;
+ }
+
+ public void add(int index, T element){
+ if(this.myArray[index] == null){
+ this.myArray[index] = element;
+ this.numberOfObjects++;
+ }
+
+ else if(this.contains(null)){
+ this.myArray = Arrays.copyOf(myArray, this.myArray.length);
+ this.shiftValuesAndReplaceTargets(index,element);
+ }
+
+ else{
+ this.myArray = Arrays.copyOf(myArray, this.myArray.length+1);
+ this.shiftValuesAndReplaceTargets(index,element);
+ }
+ }
+
+ public void addAll(T[] elements){
+ if(this.contains(null)){
+ this.myArray = Arrays.copyOf(myArray, this.newArraySize(elements));
+ int counter = this.indexOf(null) ;
+ for(int i = 0 ; i=0; i--){
+ if (this.myArray[i].equals(element)){
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public void remove(int index){
+ T[] tempArray = (T[]) new Object[0];
+ for(int i = 0; i endIndex){
+ tempArray = Arrays.copyOf(tempArray,tempArray.length+1);
+ tempArray[tempArray.length-1] = this.myArray[i];
+ }
+ }
+ tempArray = Arrays.copyOf(tempArray,tempArray.length+(endIndex-startIndex)+1);
+ this.myArray = tempArray;
+ this.numberOfObjects -= (endIndex - startIndex)+1;
+
+ }
+
+ public int size(){
+ return this.numberOfObjects;
+ }
+
+ public T[] subArray(int startIndex, int endIndex, T[] newArray){
+ T[] tempArray = (T[]) new Object[0];
+ int counter = 0;
+ for(int i = startIndex; i <= endIndex; i++){
+ tempArray = Arrays.copyOf(tempArray,tempArray.length+1);
+ tempArray[counter] = this.myArray[i];
+ counter++;
+ }
+ return (T[]) Arrays.copyOf(tempArray, tempArray.length, newArray.getClass());
+ }
+
+ public T[] toArray(T[] newArray){
+
+ return (T[]) Arrays.copyOf(this.myArray, this.myArray.length, newArray.getClass());
+ }
+
+ public void trimToSize(){
+ this.myArray = Arrays.copyOf(this.myArray, this.size());
+
+ }
+
+ private int countNulls(){
+ int counter = 0;
+ for (T t : this.myArray){
+ if (t == null){
+ counter++;
+ }
+ }
+ return counter;
+ }
+
+ private int newArraySize(T[] input){
+ if(this.countNulls() >= input.length){
+ return this.myArray.length;
+ }
+ else{
+ return this.myArray.length + (input.length-this.countNulls());
+ }
+ }
+
+ private void shiftValuesAndReplaceTargets(int index, T ... elements){
+ int count = index;
+ T[] tempArray = Arrays.copyOf(myArray, myArray.length);
+ for(int i = (index+elements.length); i {
+
+ private MySet mapSet;
+
+ public MyMap(){
+ mapSet = new MySet<>();
+
+ }
+
+ public void clear(){
+ mapSet.clear();
+
+ }
+
+ public boolean containsKey(K key){
+ for(Mapping m : mapSet.toArray(new Mapping[0])){
+ if(m.getKey().equals(key)) return true;
+ }
+ return false;
+ }
+
+ public boolean containsValue(V value){
+ for(Mapping m : mapSet.toArray(new Mapping[0])){
+ if(m.getValue().equals(value)) return true;
+ }
+ return false;
+ }
+
+ public V get(K key){
+ for(Mapping m : mapSet.toArray(new Mapping[0])){
+ if(m.getKey().equals(key)) return (V) m.getValue();
+ }
+ return null;
+ }
+
+ public void put(K key, V value){
+ Mapping m = new Mapping (key,value);
+ mapSet.add(m);
+
+ }
+
+ public int size(){
+ return mapSet.size();
+ }
+
+
+
+
+}
diff --git a/src/main/java/MySet.java b/src/main/java/MySet.java
new file mode 100644
index 0000000..4940cfb
--- /dev/null
+++ b/src/main/java/MySet.java
@@ -0,0 +1,60 @@
+public class MySet {
+
+ private MyArrayList setList;
+
+ public MySet(){
+ setList = new MyArrayList<>();
+
+ }
+
+ public MySet(T[] initialArray){
+ setList = new MyArrayList<>();
+ for(T t : initialArray) {
+ if (!setList.contains(t)) setList.add(t);
+ }
+
+ }
+
+ public MySet(int initialCapacity){
+ setList = new MyArrayList<>(initialCapacity);
+
+ }
+
+ public void add(T element){
+ if(!setList.contains(element)) {
+ setList.add(element);
+ }
+
+ }
+
+ public void clear(){
+ setList.clear();
+ }
+
+ public boolean contains(T element){
+ return setList.contains(element);
+ }
+
+ public boolean isEmpty(){
+ return setList.isEmpty();
+ }
+
+ public void remove(T element){
+ setList.remove(element);
+
+ }
+
+ public int size(){
+ return setList.size();
+ }
+
+ public T[] toArray (T[] typeArray){
+ return setList.toArray(typeArray);
+ }
+
+
+
+
+
+
+}
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/MappingTest.java b/src/test/java/MappingTest.java
new file mode 100644
index 0000000..a9c51fa
--- /dev/null
+++ b/src/test/java/MappingTest.java
@@ -0,0 +1,62 @@
+import org.junit.Assert;
+import org.junit.Test;
+
+@SuppressWarnings("unchecked")
+public class MappingTest {
+
+ @Test
+ public void newMappingTest(){
+ //Given
+ Mapping test = new Mapping("Test", 1);
+
+ //When
+ Integer expectedValue = 1;
+ String expectedKey = "Test";
+ Integer actualValue = test.getValue();
+ String actualKey = test.getKey();
+
+ //Then
+ Assert.assertEquals(expectedKey,actualKey);
+ Assert.assertEquals(expectedValue,actualValue);
+ }
+
+ @Test
+ public void setValueTest(){
+ //Given
+ Mapping test = new Mapping("Test", 1);
+
+ //When
+ test.setValue(5);
+ int expected = 5;
+ int actual = test.getValue();
+
+ //Then
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void equalsTest(){
+ //Given
+ Mapping test = new Mapping("Test", 1);
+ Mapping test2 = new Mapping("Test", 5);
+
+ //When
+
+ //Then
+ Assert.assertTrue(test.equals(test2));
+ }
+
+ @Test
+ public void equalsFalseTest(){
+ //Given
+ Mapping test = new Mapping("Test", 1);
+ Mapping test2 = new Mapping("T3st", 1);
+
+ //When
+
+ //Then
+ Assert.assertFalse(test.equals(test2));
+ }
+
+
+}
diff --git a/src/test/java/MyArrayListTest.java b/src/test/java/MyArrayListTest.java
new file mode 100644
index 0000000..0a0d6e8
--- /dev/null
+++ b/src/test/java/MyArrayListTest.java
@@ -0,0 +1,322 @@
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MyArrayListTest {
+
+ @Test
+ public void nullaryConstructorTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>();
+
+ //When
+ int expected = 0;
+ int actual = test.size();
+
+ //Then
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void intConstructorTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(5);
+
+ //When
+ int expected = 0;
+ int actual = test.size();
+
+ //Then
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void intAddNullsTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(5);
+
+ //When
+ test.add(null);
+ test.add(null);
+ test.add(null);
+ int expected = 3;
+ int actual = test.size();
+
+ //Then
+ Assert.assertEquals(expected,actual);
+ }
+
+
+ @Test
+ public void addElementTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(0);
+
+ //When
+ test.add(10);
+ int expected =10;
+ int actual = test.get(0);
+
+ //Then
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void addElementIndexTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(3);
+
+ //When
+ test.add(10);
+ test.add(0,25);
+ int expected =25;
+ int actual = test.get(0);
+ Integer[] expected2 = {25,10,null};
+
+ //Then
+ Assert.assertEquals(expected,actual);
+ Assert.assertArrayEquals(expected2,test.toArray(new Integer[0]));
+ }
+
+ @Test
+ public void addAllTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(3);
+
+
+ //When
+ Integer[] expected = {5,10,15,20};
+ test.addAll(expected);
+ Integer [] actual = test.toArray(new Integer[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ }
+
+ @Test
+ public void addAllWithNullsTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(6);
+
+
+ //When
+ Integer[] expected = {5,10,15,20,null,null};
+ test.addAll(expected);
+ Integer [] actual = test.toArray(new Integer[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ }
+
+ @Test
+ public void addAllIndexTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(0);
+ test.add(0);
+ test.add(25);
+
+
+ //When
+ Integer[] values = {5,10,15,20};
+ test.addAll(1,values);
+ Integer[] expected = {0,5,10,15,20,25};
+ Integer [] actual = test.toArray(new Integer[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ }
+
+ @Test
+ public void addAllIndexWithNullsTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(8);
+ test.add(0);
+ test.add(25);
+
+
+
+ //When
+ Integer[] values = {5,10,15,20};
+ test.addAll(1,values);
+ Integer[] expected = {0,5,10,15,20,25,null,null};
+ Integer [] actual = test.toArray(new Integer[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ }
+
+ @Test
+ public void clearTest() {
+ //Given
+ MyArrayList test = new MyArrayList<>(3);
+ test.add(0);
+ test.add(25);
+
+ //When
+ test.clear();
+ int expected = 0;
+ int actual = test.size();
+
+ //Then
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void containsTest() {
+ //Given
+ MyArrayList test = new MyArrayList<>(0);
+ test.add(0);
+ test.add(25);
+
+ //Then
+ Assert.assertTrue(test.contains(25));
+ }
+
+ @Test
+ public void indexOfTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(0);
+ test.add(0);
+ test.add(25);
+
+ //When
+ int expected = 1;
+ int actual = test.indexOf(25);
+
+ //Then
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void isEmptyTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(5);
+
+ //Then
+ Assert.assertFalse(test.isEmpty());
+ }
+
+ @Test
+ public void isEmptyFalseTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(5);
+ test.add(25);
+
+ //Then
+ Assert.assertFalse(test.isEmpty());
+ }
+
+ @Test
+ public void lastIndexOfTest() {
+ //Given
+ MyArrayList test = new MyArrayList<>(0);
+ Integer[] testElements = {5,10,5,10,10};
+ test.addAll(testElements);
+
+ //When
+ int expected = 2;
+ int actual = test.lastIndexOf(5);
+
+ //Then
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void setTest() {
+ //Given
+ MyArrayList test = new MyArrayList<>(0);
+ Integer[] testElements = {5, 10, 5, 10, 10};
+ test.addAll(testElements);
+
+ //When
+ test.set(2,15);
+ int expected = 15;
+ int actual = test.get(2);
+
+ //Then
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void removeIndexTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(0);
+ Integer[] testElements = {5, 10, 5, 15, 20};
+ test.addAll(testElements);
+
+ //When
+ test.remove(2);
+ Integer[] expected = {5,10,15,20,null};
+ Integer[] actual = test.toArray(new Integer[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ Assert.assertTrue(test.size() == 4);
+ }
+
+ @Test
+ public void removeElementTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(0);
+ Integer[] testElements = {5, 10, 5, 15, 20};
+ test.addAll(testElements);
+
+ //When
+ Integer value = 5;
+ test.remove(value);
+ Integer[] expected = {10,5,15,20,null};
+ Integer[] actual = test.toArray(new Integer[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ Assert.assertTrue(test.size() == 4);
+ }
+
+ @Test
+ public void removeRangeTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(0);
+ Integer[] testElements = {5, 10, 5, 15, 20};
+ test.addAll(testElements);
+
+ //When
+ test.removeRange(1,3);
+ Integer[] expected = {5,20,null,null,null};
+ Integer[] actual = test.toArray(new Integer[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ Assert.assertTrue(test.size() == 2);
+ }
+
+ @Test
+ public void subArrayTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(0);
+ Character[] testElements = {'a','b','c','d','e','f'};
+ test.addAll(testElements);
+
+ //When
+ Character[] expected = {'b','c','d','e'};
+ Character[] actual = test.subArray(1,4, new Character[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ }
+
+ @Test
+ public void trimToSizeTest(){
+ //Given
+ MyArrayList test = new MyArrayList<>(6);
+ String [] elements = {"Hi", "I", "Am", "trimming"};
+ test.addAll(elements);
+
+ //When
+ test.trimToSize();
+ String[] expected = {"Hi", "I", "Am", "trimming"};
+ String[] actual = test.toArray(new String[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ }
+
+}
diff --git a/src/test/java/MyMapTest.java b/src/test/java/MyMapTest.java
new file mode 100644
index 0000000..5dad5c9
--- /dev/null
+++ b/src/test/java/MyMapTest.java
@@ -0,0 +1,87 @@
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MyMapTest {
+
+ @Test
+ public void newMapTest(){
+ //Given
+ MyMap test = new MyMap<>();
+
+ //When
+ int expected = 0;
+ int actual = test.size();
+
+ //Then
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void putTest(){
+ //Given
+ MyMap test = new MyMap<>();
+
+ //When
+ test.put("Test",5);
+ Integer expected = 5;
+ Integer actual = test.get("Test");
+
+ //Then
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void putDuplicatesTest(){
+ //Given
+ MyMap test = new MyMap<>();
+
+ //When
+ test.put("Test",5);
+ test.put("Test",5);
+ test.put("Test",5);
+
+ //Then
+ Assert.assertTrue(test.size() == 1);
+ }
+
+ @Test
+ public void containsKeyTest(){
+ //Given
+ MyMap test = new MyMap<>();
+
+ //When
+ test.put("Test",5);
+
+ //Then
+ Assert.assertTrue(test.containsKey("Test"));
+ }
+
+ @Test
+ public void containsValueTest(){
+ //Given
+ MyMap test = new MyMap<>();
+
+ //When
+ test.put("Test",5);
+
+ //Then
+ Assert.assertTrue(test.containsValue(5));
+ }
+
+ @Test
+ public void clearTest(){
+ //Given
+ MyMap test = new MyMap<>();
+
+ //When
+ test.put("Test", 5);
+ test.clear();
+
+ //Then
+ Assert.assertTrue(test.size()==0);
+ }
+
+
+
+
+}
diff --git a/src/test/java/MySetTest.java b/src/test/java/MySetTest.java
new file mode 100644
index 0000000..cdc27d7
--- /dev/null
+++ b/src/test/java/MySetTest.java
@@ -0,0 +1,147 @@
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MySetTest {
+
+ @Test
+ public void nullaryConstructorTest(){
+ //Given
+ MySet test = new MySet<>();
+
+ //When
+ int expected = 0;
+ int actual = test.size();
+
+ //Then
+ Assert.assertEquals(expected,actual);
+ }
+
+ @Test
+ public void capacityConstructorTest(){
+ //Given
+ MySet test = new MySet<>(5);
+
+ //When
+ Character[] expected = {null,null,null,null,null};
+ Character [] actual = test.toArray(new Character[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ Assert.assertTrue(test.size()==0);
+ }
+
+ @Test
+ public void arrayConstructorTest(){
+ //Given
+ String[] testInput = {"This", "is", "a", "test"};
+ MySet test = new MySet<>(testInput);
+
+ //When
+ String[] expected = {"This", "is", "a", "test"};
+ String [] actual = test.toArray(new String[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ Assert.assertTrue(test.size()==4);
+ }
+
+ @Test
+ public void arrayConstructorWithDuplicateTest(){
+ //Given
+ String[] testInput = {"This", "is", "a", "test", "This", "is", "a", "test"};
+ MySet test = new MySet<>(testInput);
+
+ //When
+ String[] expected = {"This", "is", "a", "test"};
+ String [] actual = test.toArray(new String[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ Assert.assertTrue(test.size()==4);
+ }
+
+ @Test
+ public void addTest(){
+ //Given
+ MySet test = new MySet<>(5);
+ test.add('a');
+ test.add('b');
+
+ //When
+ Character[] expected = {'a','b',null,null,null};
+ Character [] actual = test.toArray(new Character[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ }
+
+ @Test
+ public void dontAddDuplicatesTest(){
+ //Given
+ MySet test = new MySet<>(5);
+ test.add(1);
+ test.add(2);
+ test.add(1);
+ test.add(2);
+
+ //When
+ Integer[] expected = {1,2,null,null,null};
+ Integer [] actual = test.toArray(new Integer[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ Assert.assertTrue(test.size()==2);
+ }
+
+ @Test
+ public void clearTest(){
+ //Given
+ String[] testInput = {"This", "is", "a", "test"};
+ MySet test = new MySet<>(testInput);
+
+ //When
+ test.clear();
+ String[] expected = {null,null,null,null};
+ String [] actual = test.toArray(new String[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ Assert.assertTrue(test.size()==0);
+ }
+
+ @Test
+ public void containsTest(){
+ //Given
+ Double[] testInput = {5d,9d,3.14,8d};
+ MySet test = new MySet<>(testInput);
+
+ //Then
+ Assert.assertTrue(test.contains(3.14));
+ }
+
+ @Test
+ public void isEmptyTest(){
+ //Given
+ MySet test = new MySet<>(5);
+
+ //Then
+ Assert.assertTrue(test.isEmpty());
+ }
+
+ @Test
+ public void removeTest(){
+ //Given
+ String[] testInput = {"This", "is", "a", "test"};
+ MySet test = new MySet<>(testInput);
+
+ //When
+ test.remove("This");
+ String[] expected = {"is", "a", "test",null};
+ String [] actual = test.toArray(new String[0]);
+
+ //Then
+ Assert.assertArrayEquals(expected,actual);
+ Assert.assertTrue(test.size()==3);
+ }
+
+}