Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<kotlin.version>1.2.30</kotlin.version>
</properties>


Expand All @@ -21,7 +22,67 @@
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>


</project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.zipcodewilmington.arrayutility;

import java.util.ArrayList;
import java.util.Arrays;

/**
* Created by leon on 3/6/18.
*/
public class ArrayUtility<T>{

T[] array;


public ArrayUtility(T[] inputArray) {
this.array = inputArray;
}


public int getNumberOfOccurrences(T valueToEvaluate){
int count = 0;
for (int i = 0; i < array.length; i ++){
if (array[i].equals(valueToEvaluate)){
count++;
}
}
return count;
}

public int countDuplicatesInMerge(T[] inputArray, T valueToEvaluate){
int count = 0;
for (T element : inputArray){
if (element.equals(valueToEvaluate)){
count++;
}
}
for (T element : this.array){
if (element.equals(valueToEvaluate)){
count++;
}
}
return count;
}
public T getMostCommonFromMerge(T[] inputArray){
int currentCount = 1;
int mostCommonCount;

T mostCommon = inputArray[0];
T tempCount;

for(int i = 1; i < inputArray.length-1; i++){
tempCount = inputArray[i];
mostCommonCount = 0;

for (int j = 0; j < inputArray.length; j++){
if (tempCount == inputArray[j]){
mostCommonCount++;
}
if (mostCommonCount > currentCount){
mostCommon = tempCount;
}
}

}
return mostCommon;
}
public T[] removeValue(T valueToRemove){
int newSize = array.length - getNumberOfOccurrences(valueToRemove);

T[] result = Arrays.copyOf(this.array, newSize);
int index = 0;

for (T value : this.array){
if (!value.equals(valueToRemove)){

result[index] = value;
index++;
}
}
return result;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
* Created by leon on 3/1/18.
* The purpose of this class is to test all classes within this package
*/
@RunWith(Suite.class)

@Suite.SuiteClasses({
CountDuplicatesInMergeTest.class,
GetMostCommonFromMergeTest.class,
GetNumberOfOccurrencesTest.class,
RemoveValueTest.class
})
public class ArrayUtilityTestSuite {
}
//@RunWith(Suite.class)
//
//@Suite.SuiteClasses({
// CountDuplicatesInMergeTest.class,
// GetMostCommonFromMergeTest.class,
// GetNumberOfOccurrencesTest.class,
// RemoveValueTest.class
//})
//public class ArrayUtilityTestSuite {
//}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.zipcodewilmington.arrayutility;

import com.zipcodewilmington.UnitTestingUtils;
import org.junit.Test;

/**
Expand Down