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/dictionaries/kieranthomas.xml b/.idea/dictionaries/kieranthomas.xml
new file mode 100644
index 0000000..c5b44c2
--- /dev/null
+++ b/.idea/dictionaries/kieranthomas.xml
@@ -0,0 +1,9 @@
+
+
+
+ deebo
+ goku
+ vegeta
+
+
+
\ 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..8ed61e4
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,718 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1520546757688
+
+
+ 1520546757688
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No facets are configured
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+ generics
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+ Maven: junit:junit:4.12
+
+
+
+
+
+
+
+
+
+
+
+
\ 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/MyArrayList.java b/src/main/java/MyArrayList.java
new file mode 100644
index 0000000..280a39a
--- /dev/null
+++ b/src/main/java/MyArrayList.java
@@ -0,0 +1,105 @@
+import java.util.Arrays;
+import java.util.ArrayList;
+
+public class MyArrayList {
+ private T[] genericArray;
+ private int size = 0;
+
+ @SuppressWarnings("unchecked")
+ public MyArrayList() {
+ this.genericArray = (T[]) new Object[0];
+ }
+
+ @SuppressWarnings("unchecked")
+ public MyArrayList(int genericArraySize) {
+ this.genericArray = (T[]) new Object[genericArraySize];
+ }
+
+ public void add(T value) {
+ T[] outputArray = Arrays.copyOf(genericArray, genericArray.length + 1);
+ outputArray[outputArray.length - 1] = value;
+ this.genericArray = outputArray;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T get(int index) {
+ return genericArray[index];
+ }
+
+ public T[] remove(int valueToRemove) {
+ T[] outputArray = Arrays.copyOf(genericArray, genericArray.length - 1);
+ for (int i = 0; i < genericArray.length; i++) {
+ if (!genericArray[i].equals(valueToRemove)) {
+ outputArray = Arrays.copyOf(outputArray, outputArray.length + 1);
+ outputArray[outputArray.length - 1] = genericArray[i];
+ }
+ }
+ return outputArray;
+ }
+
+ public T set(int index, T indexValue) {
+ T firstValue = this.genericArray[index];
+ this.genericArray[index] = indexValue;
+ return firstValue;
+ }
+
+ public void clear() { //clear all the values or 'elements' within the array, this should return null with no values after logic
+ for (int i = 0; i < genericArray.length; i++) {
+ genericArray[i] = null;
+ }
+ }
+
+ public boolean isEmpty() { //if the array is empty return true otherwise return false
+ if (genericArray.length == 0) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean contains(T desiredValue) {
+ for (int i = 0; i < genericArray.length; i++) {
+ if (desiredValue.equals(genericArray[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public int getSize() {
+ return this.genericArray.length;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T[] toArray(T[] value) { //this method should return an the elements of any type T object
+ String[] str = {"This", "is", "confusing", "af"};
+ if (genericArray.length < size)
+ return (T[]) Arrays.copyOf(str, size, value.getClass());
+ return (T[]) str;
+ }
+
+ public static class ToArrayTest { //this does not test my method but is giving me an idea for map and generic version
+ public static void main(String[] args) { //to array should return whatever elements are contained in the array
+ //Given
+ ArrayList strArrayList = new ArrayList<>();
+ strArrayList.add("Power");
+ strArrayList.add("level");
+ strArrayList.add("over");
+ strArrayList.add("9000 \n");
+
+ System.out.println("Here are the elements within this other array: \n");
+
+ for (String str : strArrayList) {
+ System.out.println("String: " + str);
+ }
+ //When
+ String stringList2[] = new String[strArrayList.size()];
+ stringList2 = strArrayList.toArray(stringList2);
+
+ System.out.println("Here are the elements within this array: \n");
+ //Then
+ for (String str : stringList2) {
+ System.out.println("String: " + str);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/MyMap.java b/src/main/java/MyMap.java
new file mode 100644
index 0000000..87e35e8
--- /dev/null
+++ b/src/main/java/MyMap.java
@@ -0,0 +1,2 @@
+public class MyMap {
+}
diff --git a/src/main/java/MySet.java b/src/main/java/MySet.java
new file mode 100644
index 0000000..32aa8ab
--- /dev/null
+++ b/src/main/java/MySet.java
@@ -0,0 +1,51 @@
+public class MySet {
+
+ private MyArrayList mySet;
+ //Only reference types can be type parameters
+ //avoiding compile time checks with generic types
+ //the compiler will cast at run time where needed
+ //Compiler will implicitly perform the type conversion
+ public MySet() {
+ mySet = new MyArrayList<>();
+ }
+
+ public void add(T value) { //add value if set does not contain it
+ if (!mySet.contains(value)) {
+ mySet.add(value);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public T get(int index) { //get the value at desired index
+ return mySet.get(index);
+ }
+
+ public void remove(int index) { //removes all elements within this set, isEmpty method will return true upon calling
+ mySet.remove(index);
+ }
+
+ public void set(int index, T value) { //set the value at a desired index
+ mySet.set(index, value);
+ }
+
+ public void clear() { //delete everything within the set
+ mySet.clear();
+ }
+
+ public boolean contains(T value) { //if the desired value is within the set return true
+ return mySet.contains(value);
+ }
+
+ public boolean isEmpty() { //if this set contains no elements return true
+ return mySet.isEmpty();
+ }
+
+ public int getSize(){ //If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE
+ return mySet.getSize(); //in this case if my generic array/ my set of type T objects has the max value return the max value
+ }
+
+ public T[] toArray(T[] value){ //Returns an array containing all elements in set depending on Type. If the array fits then it returns those values.
+ return mySet.toArray(value);//Otherwise, a new array is allocated same runtime type of the used array and the size of this set. i.e. 10 goes to 20 and so on
+
+ }
+}
\ 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/MyArrayListTest.java b/src/test/java/MyArrayListTest.java
new file mode 100644
index 0000000..053ffe6
--- /dev/null
+++ b/src/test/java/MyArrayListTest.java
@@ -0,0 +1,294 @@
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MyArrayListTest {
+ public MyArrayListTest() {
+ }
+
+ private MyArrayList myStrArrayList = new MyArrayList<>();
+ private MyArrayList myIntArrayList = new MyArrayList<>();
+ private MySet genericIntSet = new MySet<>();
+ private MySet genericStrSet = new MySet<>();
+
+ @Test
+ public void addTest1() {
+ //Given
+ int expected = 2;
+ genericIntSet.add(7);
+ genericIntSet.add(8);
+
+ //When
+ int actual = genericIntSet.getSize();
+
+ //Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void addTest2() {
+ //Given
+ int expected = 4;
+ genericStrSet.add("This");
+ genericStrSet.add("Lab");
+ genericStrSet.add("Sucks");
+ genericStrSet.add("Bruh");
+
+ //When
+ int actual = genericStrSet.getSize();
+
+ //Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getTest1() {
+ //Given
+ int expected = 5;
+ genericIntSet.add(1);
+ genericIntSet.add(2);
+ genericIntSet.add(3);
+ genericIntSet.add(4);
+ genericIntSet.add(5);
+
+ //When
+ int actual = genericIntSet.get(4);
+
+ //Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getTest2() {
+ //Given
+ String expected = "Warlock";
+ genericStrSet.add("Super");
+ genericStrSet.add("Jump");
+ genericStrSet.add("Warlock");
+ genericStrSet.add("is");
+ genericStrSet.add("easy");
+
+ //When
+ String actual = genericStrSet.get(2);
+
+ //Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void removeTest1() {
+ //Given
+ int expected = 6;
+ genericIntSet.add(1);
+ genericIntSet.add(2);
+ genericIntSet.add(3);
+ genericIntSet.add(4);
+ genericIntSet.add(5);
+ genericIntSet.add(6);
+
+ //When
+ genericIntSet.remove(6);
+ int actual = genericIntSet.getSize();
+
+ //Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void removeTest2() {
+ //Given
+ int indexToRemove = 3;
+ String expected = "Damn";
+ genericStrSet.add("Get");
+ genericStrSet.add("Money");
+ genericStrSet.add("All");
+ genericStrSet.add("Damn");
+ genericStrSet.add("Day");
+
+ //When
+ genericStrSet.remove(indexToRemove);
+ String actual = genericStrSet.get(indexToRemove);
+
+ //Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void setTest1() {
+ //Given
+ genericIntSet.add(2);
+ genericIntSet.add(3);
+ genericIntSet.add(4);
+ genericIntSet.add(5);
+ genericIntSet.add(7);
+ genericIntSet.add(90);
+
+ //When
+ genericIntSet.set(4, 6);
+ int expected = 6;
+ int actual = genericIntSet.getSize();
+
+ //Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void setTest2() {
+ //Given
+ genericStrSet.add("My");
+ genericStrSet.add("Favorite");
+ genericStrSet.add("Color");
+ genericStrSet.add("Is");
+ genericStrSet.add("Blue");
+
+ //When
+ genericStrSet.set(4, "Red");
+ String expected = "Red";
+ String actual = genericStrSet.get(4);
+
+ //Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void clearTest1() {
+ //Given
+ genericIntSet.add(6);
+ genericIntSet.add(7);
+ genericIntSet.add(34);
+ genericIntSet.add(9);
+ genericIntSet.add(5);
+ genericIntSet.add(4);
+ genericIntSet.add(44);
+ genericIntSet.add(3);
+ int expected = 8;
+
+ //When
+ genericIntSet.clear();
+ int actual = genericIntSet.getSize();
+
+ //Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void clearTest2() {
+ //Given
+ genericStrSet.add("Goku");
+ int expected = 1;
+
+ //When
+ genericStrSet.clear();
+ int actual = genericStrSet.getSize();
+
+ //Then
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void containsTest1() {
+ //Given
+ genericIntSet.add(8);
+ genericIntSet.add(7);
+ genericIntSet.add(4);
+ boolean expected = true;
+
+ //When
+ boolean actual = genericIntSet.contains(4);
+
+ //Then
+ Assert.assertEquals(true, actual);
+ }
+
+ @Test
+ public void containsTest2() {
+ //Given
+ genericStrSet.add("I");
+ genericStrSet.add("Want");
+ genericStrSet.add("Red's");
+ genericStrSet.add("Money");
+ boolean expected = true;
+
+ //When
+ boolean actual = genericStrSet.contains("Money");
+
+ //Then
+ Assert.assertEquals(true, actual);
+ }
+
+ @Test
+ public void containsTest3() {
+ //Given
+ genericIntSet.add(8);
+ genericIntSet.add(7);
+ genericIntSet.add(4);
+ genericIntSet.add(12);
+ boolean expected = false;
+
+ //When
+ boolean actual = genericIntSet.contains(11);
+
+ //Then
+ Assert.assertEquals(false, actual);
+ }
+
+ @Test
+ public void containsTest4() {
+ //Given
+ genericStrSet.add("I");
+ genericStrSet.add("Want");
+ genericStrSet.add("Red's");
+ genericStrSet.add("Money");
+ boolean expected = false;
+
+ //When
+ boolean actual = genericStrSet.contains("Deebo");
+
+ //Then
+ Assert.assertEquals(false, actual);
+ }
+
+ @Test
+ public void isEmptyTest1() {
+ //Given
+ myIntArrayList.add(2);
+ boolean expected = false;
+
+ //When
+ //clear/Remove method never used so it should still contain its value
+ boolean actual = myIntArrayList.isEmpty();
+
+ //Then
+ Assert.assertEquals(false, actual);
+ }
+
+ @Test
+ public void isEmptyTest2() {
+ //Given
+ genericStrSet.add("Vegeta");
+ boolean expected = false;
+
+ //When
+ //clear/Remove method never used so it should still contain its value
+ boolean actual = genericStrSet.isEmpty();
+
+ //Then
+ Assert.assertEquals(false, actual);
+ }
+//
+// @Test
+// public void toArrayTest() {
+// //Given
+// String[] strings = new String[myStrArrayList.getSize()];
+// myStrArrayList.add("Hope");
+// myStrArrayList.add("This");
+// myStrArrayList.add("Works");
+// expected
+// //When
+// myStrArrayList.toArray(strings);
+// actual
+//
+// //Then
+// Assert.assertEquals(expected, actual);
+//
+// }
+}
\ No newline at end of file