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..e8942bd
--- /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..c9ec99b
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,780 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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/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..399bd44
--- /dev/null
+++ b/src/main/java/MyArrayList.java
@@ -0,0 +1,36 @@
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class MyArrayList extends MyCollections{
+ private final static int DEFAULT_SIZE = 10;
+
+ public MyArrayList(int length) {
+ super(length);
+ }
+ /* if there is no size given create Default with size of 10.*/
+ public MyArrayList() {
+ super(DEFAULT_SIZE);
+ }
+
+ @Override
+ public boolean equals(Object theObject) {
+ return false;
+ }
+
+ //adds to a specific index.
+ public boolean add(E theObject, int index) {
+ int size = getSize();
+ E[] objects = (E[]) getNumbers();
+ ensureCapacity(size + 1);
+
+ System.arraycopy(getNumbers(), index, objects, index + 1,
+ size - index);
+ objects[index] = theObject;
+ super.incrementSizeByOne();
+ return true;
+ }
+
+
+
+}
diff --git a/src/main/java/MyCollections.java b/src/main/java/MyCollections.java
new file mode 100644
index 0000000..4ae2f5a
--- /dev/null
+++ b/src/main/java/MyCollections.java
@@ -0,0 +1,146 @@
+
+import java.util.Arrays;
+
+public abstract class MyCollections {
+ protected final static int DEFAULT_SIZE = 10;
+ private E[] numbers;
+ private boolean isEmpty = false;
+ private int sizeOfList;
+ private int capacitiy;
+ private int nullValues;
+
+ public MyCollections(int length) {
+ sizeOfList = 0;
+ capacitiy = length;
+ if (length > 0) {
+ this.numbers = (E[]) new Object[length];
+ }
+
+ }
+
+ /* if there is no size given create Default with size of 10.*/
+ public MyCollections() {
+ this(DEFAULT_SIZE);
+ }
+
+ public void ensureCapacity(int sizeOfList) {
+ if (sizeOfList - getCapacity() > 0) {
+ grow();
+ }
+ }
+
+ public void grow() {
+ int oldCapacity = numbers.length;
+ int newCapacity = oldCapacity + DEFAULT_SIZE;
+ numbers = Arrays.copyOf(numbers, newCapacity);
+ }
+
+
+
+
+ //adds to the last index
+ public boolean add(E theObject) {
+ ensureCapacity(sizeOfList + 1);
+ numbers[sizeOfList++] = theObject;
+ return true;
+ }
+
+
+ public boolean remove(E theObject) {
+ boolean removed = false;
+ int index = indexOf(theObject);
+ if (index != -1) {
+ removed = removeFromList(index);
+ }
+ return removed;
+ }
+
+ public boolean removeFromList(int index) {
+ numbers[index] = null;
+ for (int i = index; i < sizeOfList; i++) {
+
+ if (numbers[i + 1] != null) {
+ numbers[i] = numbers[i + 1];
+ }
+ }
+ nullValues++;
+ sizeOfList--;
+ return true;
+ }
+
+
+ public boolean isEmpty() {
+ return this.isEmpty;
+ }
+
+ // clears array by setting new array to size zero;
+ public void clear() {
+ sizeOfList = 0;
+ clearAllResize();
+ }
+
+ public boolean contains(E theObject) {
+ boolean contains = false;
+ for (E object : numbers) {
+ if (theObject.equals(object))
+ contains = true;
+ }
+ return contains;
+ }
+
+ public int getSize() {
+ return this.sizeOfList;
+ }
+
+ public int getCapacity() {
+ return numbers.length;
+ }
+
+ public E get(int index) {
+
+ if (index >= 0 && index <= sizeOfList) {
+ return numbers[index];
+ }
+ return null;
+ }
+
+ public int indexOf(E theObject) {
+ for (int i = 0; i < sizeOfList; i++) {
+ if (theObject.equals(numbers[i]))
+ return i;
+ }
+ return -1;
+ }
+
+ public int getNumberOfNulls() {
+ return this.nullValues;
+ }
+
+ public void reSizeList() {
+ int oldCapasity = numbers.length;
+ int newCapasity = oldCapasity - DEFAULT_SIZE;
+ if (newCapasity > 10 && nullValues == 10) {
+ reSize();
+ }
+ }
+
+ public void reSize() {
+ numbers = Arrays.copyOf(numbers, numbers.length - DEFAULT_SIZE);
+ }
+
+ public void clearAllResize() {
+ numbers = Arrays.copyOf(numbers, DEFAULT_SIZE);
+ for (E number : numbers) {
+ number = null;
+ }
+ }
+ public void incrementSizeByOne(){
+ sizeOfList++;
+ }
+
+ public E[] getNumbers() {
+ return numbers;
+ }
+
+}
+
diff --git a/src/main/java/MySet.java b/src/main/java/MySet.java
new file mode 100644
index 0000000..aa12e57
--- /dev/null
+++ b/src/main/java/MySet.java
@@ -0,0 +1,35 @@
+import com.sun.tools.classfile.Opcode;
+
+import java.util.Set;
+
+public class MySet extends MyCollections {
+ public MySet() {
+ super(DEFAULT_SIZE);
+ }
+
+ @Override
+ public boolean add(E theObject) {
+ boolean added = false;
+ if (!contains(theObject))
+ super.add(theObject);
+ added = true;
+ return added;
+ }
+
+
+ @Override
+ public boolean equals(Object theObject) {
+ //check to see if TheObject is an instance of the set
+ // check to see if sizes are the same
+ // check to see if the one set contains all the same object
+ if (!(theObject instanceof MySet)) {
+ return false;
+ }
+ if ((((MySet) theObject).getSize() != getSize()))
+ if (!((MySet) theObject).contains(theObject)) {
+ return false;
+ }
+
+ return theObject.equals(getNumbers());
+ }
+}
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/MyArrayListAddTest.java b/src/test/java/MyArrayListAddTest.java
new file mode 100644
index 0000000..86d782c
--- /dev/null
+++ b/src/test/java/MyArrayListAddTest.java
@@ -0,0 +1,56 @@
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class MyArrayListAddTest{
+
+ private MyArrayList theList;
+ private Integer[] numbers;
+
+ @Before
+ public void setUp() throws Exception {
+
+ Integer size = 6;
+ theList = new MyArrayList(size);
+ numbers = new Integer[]{1, 5, 7, 8, 9, 10};
+ }
+
+ @Test
+ public void addIntegerTest() {
+
+ Integer test1 = 7;
+ boolean expected = true;
+ boolean actual = theList.add(test1);
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void addStringTest() {
+
+ String test1 = "the Book";
+ Integer test2 = 2;
+ theList.add(test1);
+ theList.add(test2);
+ boolean expected = true;
+ boolean actual = theList.contains(test2);
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void addToSpecificIndex() {
+ for (int i = 1; i < 13; i++) {
+ theList.add(i);
+ }
+ theList.add(5, 7);
+
+ int expected = 5;
+ int actual = (Integer)theList.get(7);
+
+ assertEquals(expected, actual);
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/MyArrayListTest.java b/src/test/java/MyArrayListTest.java
new file mode 100644
index 0000000..ed10030
--- /dev/null
+++ b/src/test/java/MyArrayListTest.java
@@ -0,0 +1,217 @@
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+
+import static org.junit.Assert.*;
+
+public class MyArrayListTest {
+ private int length;
+ private int size;
+ private MyArrayList theList;
+ private Integer[] numbers;
+
+ @Before
+ public void setUp() throws Exception {
+ size = 0;
+ length = 6;
+ theList = new MyArrayList(length);
+ numbers = new Integer[]{1, 5, 7, 8, 9, 10};
+ }
+
+ @Test
+ public void ensureCapacityStaysSameTest() {
+ // check to see if current size - current length is great 0
+ // if its < grow the array by 10;
+ theList.ensureCapacity(size + 1);
+ int expected = 6;
+ int actual = theList.getCapacity();
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void ensureCapacityGrowsTest() {
+ // check to see if current size - current length is great 0
+ // if its < grow the array by 10;
+ theList.ensureCapacity(+8);
+ int expected = 16;
+ int actual = theList.getCapacity();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void growTest() {
+ theList.grow();
+ int expected = numbers.length + 10;
+ int actual = theList.getSize();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getAtSpecificIndexMixTest() {
+ int index = 0;
+ String test1 = "the Book";
+ Integer test2 = 2;
+ theList.add(test1);
+ theList.add(test2);
+
+ String expected = test1;
+ String actual = (String) theList.get(index);
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getAtSpecificIndexStringTest() {
+ int index = 0;
+ String[] names = new String[]{"dave", "the Cat", "Bob", "Tim", "something", "anotherOne"};
+
+ theList.add(names[0]);
+ theList.add(names[1]);
+ theList.add(names[2]);
+
+ String expected = "dave";
+ String actual = (String) theList.get(index);
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getAtSpecificIndexIntegerTest() {
+ int index = 0;
+ Integer[] num = new Integer[]{1, 3, 5};
+
+ theList.add(num[0]);
+ theList.add(num[1]);
+ theList.add(num[2]);
+
+ Integer expected = 1;
+ Integer actual = (Integer) theList.get(index);
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void getNullTest() {
+ int index = 12;
+ String[] names = new String[]{"dave", "the Cat", "Bob", "Tim", "something", "anotherOne"};
+
+ theList.add(names[0]);
+ theList.add(names[1]);
+ theList.add(names[2]);
+
+ String expected = null;
+ String actual = (String) theList.get(index);
+
+ Assert.assertEquals(expected, actual);
+ }
+
+
+ @Test
+ public void removeTest() {
+ int index = 12;
+ String[] names = new String[]{"dave", "the Cat", "Bob"};
+
+ theList.add(names[0]);
+ theList.add(names[1]);
+ theList.add(names[2]);
+ theList.remove(names[1]);
+
+ int expected = 2;
+ int actual = theList.getSize();
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void removeCheckIfContainsObjectTest() {
+ int index = 12;
+ String[] names = new String[]{"dave", "the Cat", "Bob"};
+
+ theList.add(names[0]);
+ theList.add(names[1]);
+ theList.add(names[2]);
+ theList.remove(names[1]);
+
+ boolean expected = false;
+ boolean actual = theList.contains("the Cat");
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void removeCheckObjectsWhereShiftedTest() {
+ int index = 12;
+ String[] names = new String[]{"dave", "the Cat", "Bob"};
+
+ theList.add(names[0]);
+ theList.add(names[1]);
+ theList.add(names[2]);
+ theList.remove(names[1]);
+
+ int expected = 1;
+ int actual = theList.indexOf("Bob");
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void removeObjecDoesNotExistTest() {
+ int index = 12;
+ String[] names = new String[]{"dave", "the Cat", "Bob"};
+
+ theList.add(names[0]);
+ theList.add(names[1]);
+ theList.add(names[2]);
+ theList.remove(names[1]);
+ theList.remove("the Cat");
+ boolean expected = false;
+ boolean actual = theList.remove("the Cat");
+ Assert.assertEquals(expected, actual);
+ }
+
+
+ @Test
+
+ public void indexOfTest() {
+
+ String[] names = new String[]{"dave", "the Cat", "Bob"};
+
+ theList.add(names[0]);
+ theList.add(names[1]);
+ theList.add(names[2]);
+
+ int expected = 2;
+ int actual = theList.indexOf("Bob");
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void indexOfNullTest() {
+ int index = 12;
+ String[] names = new String[]{"dave", "the Cat", "Bob"};
+
+ theList.add(names[0]);
+ theList.add(names[1]);
+ theList.add(names[2]);
+
+ int expected = -1;
+ int actual = theList.indexOf(12);
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+
+ public void clearTest() {
+ for (int i = 0; i < 50; i++) {
+ theList.add(i);
+ }
+ theList.clear();
+
+ int expected = 10;
+ int actual = theList.getCapacity();
+
+ assertEquals(expected, actual);
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/test/java/MySetTest.java b/src/test/java/MySetTest.java
new file mode 100644
index 0000000..d3e084d
--- /dev/null
+++ b/src/test/java/MySetTest.java
@@ -0,0 +1,40 @@
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class MySetTest {
+ private MySet theSet;
+
+ @Before
+ public void setUp() throws Exception {
+ theSet = new MySet<>();
+ for (int i = 0; i <= 10; i++) {
+ theSet.add(i);
+ }
+ }
+
+ @Test
+ public void addTest() {
+ theSet.add(11);
+ int expected = 12;
+ int acutal = theSet.getSize();
+
+ Assert.assertEquals(expected, acutal);
+ }
+
+ @Test
+ public void addNoDuplicatesTest() {
+ theSet.add(10);
+ int expected = 11;
+ int acutal = theSet.getSize();
+
+ Assert.assertEquals(expected, acutal);
+ }
+
+
+ @Test
+ public void equals() {
+ }
+}
\ No newline at end of file