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
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

public class BasicUtilities {
public Boolean isGreaterThan5(Integer value) {
return null;
return value >= 5;
}

public Boolean isLessThan7(Integer value) {
return null;
return value<= 7;
}

public Boolean isBetween5And7(Integer valueToEvaluate) {
return null;

return isGreaterThan5(valueToEvaluate)&& isLessThan7(valueToEvaluate);
}

public Boolean startsWith(String string, Character character) {
return null;

return(string.charAt(0)== character || string.toLowerCase().charAt(0)==character);
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
package com.zipcodewilmington.assessment2.part1;

import sun.security.util.Length;

public class IntegerArrayUtilities {
public Boolean hasEvenLength(Integer[] array) {
return null;
return array.length % 2==0;
}

public Integer[] range(int start, int stop) {
return null;
int size =Math.abs(stop - start)+1;

Integer[] range= new Integer[size];
for(int i=0; i<range.length;i++)
range[i]=start+i;
return range;


}

public Integer getSumOfFirstTwo(Integer[] array) {
return null;
return array[0]+ array[1];
}

public Integer getProductOfFirstTwo(Integer[] array) {
return null;
int lastIdx = array.length -1;
return array[lastIdx]* array[lastIdx -1];
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package com.zipcodewilmington.assessment2.part1;

public class WuTangConcatenator {

private Integer input;
public WuTangConcatenator(Integer input) {
}

this.input =input;
}
public Boolean isWu() {
return null;


return input%3 ==0;

}

public Boolean isTang() {
return null;
}

public Boolean isWuTang() {
return null;
return input % 5==0;
}
}

public Boolean isWuTang() {
return isWu()&& isTang();

}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,81 @@
package com.zipcodewilmington.assessment2.part2;

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

public class ArrayUtility {
public Integer[] merge(Integer[] array1, Integer[] array2) {
return null;

ArrayList<Integer>newList=new ArrayList<Integer>();


int newLength =array1.length+ array2.length;
newList.addAll(Arrays.asList(array1));
newList.addAll(Arrays.asList(array2));
return newList.toArray(new Integer[newLength]);
}

public Integer[] rotate(Integer[] array, Integer index) {
return null;
}

Integer[] newArray = new Integer[array.length];
for (int i = array.length - 1; i >= 0; i--) {
if (i - index >= 0) {
newArray[i - index] = array[i];
} else {
newArray[i - index + array.length] = array[i];
}
}
return newArray;
}
public static Integer getNumberOfOcurrences(Integer[] array, Integer valueToCount) {
int numOfOccurrences = 0;
for (Integer value : array) {
if (value == valueToCount)
numOfOccurrences = numOfOccurrences + 1;
}
return numOfOccurrences;
}
public Integer countOccurrence(Integer[] array1, Integer[] array2, Integer valueToEvaluate) {
return null;
//Integer[] mergedArray= merge[array1,array2];
return null;//getNumberOfOcurrences(mergedArray, valueToEvaluate);
}


public Integer mostCommon(Integer[] array) {
return null;
}
}
int count = 1, tempCount;
int popular = array[0];
int temp = 0;
for (int i = 0; i < (array.length - 1); i++)
temp = array[i];
{
tempCount = 0;
for (int j = 1; j < array.length; j++) {
if (temp == array[j])
tempCount++;
}
if (tempCount > count) {
popular = temp;
count = tempCount;

}
}
return popular;

//Integer[] occurrences = new Integer[array.length];
// for (int i = 0; i < array.length; i++) {
// occurrences[i] = getNumberOfOccurrences(array, array[i]);
// }
// find most common (max # of occurrences) and return
//int max = occurrences[0];
// int maxIdx = 0;
// for (int i = 1; i < occurrences.length; i++) {
// if (occurrences[i] > max) {
// max = occurrences[i];
// maxIdx = i;
// }
// }

}}



Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
package com.zipcodewilmington.assessment2.part3;

public class BlueJay {
public class BlueJay extends Bird {
public BlueJay(){

}


public String color() {
return "blue";
}
public int getSpeed(){
return 13;
}
}
12 changes: 11 additions & 1 deletion src/main/java/com/zipcodewilmington/assessment2/part3/Horse.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
package com.zipcodewilmington.assessment2.part3;

public class Horse{
public class Horse implements Animal{
public String move(){
return "gallop";
}
public String color(){
return "brown";
}

public int getSpeed() {
return 40;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
package com.zipcodewilmington.assessment2.part3;

public class RedRobin {
public class RedRobin extends Bird{
String migrationMonth;
public RedRobin(){
}


public String color(){
return "red";

}
public int getSpeed(){
return 10;
}


@Override
public String getMigrationMonth() {
return migrationMonth;
}
@Override
public void setMigrationMonth(String migrationMonth){
this.migrationMonth = migrationMonth;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package com.zipcodewilmington.assessment2.part3;

public class SpeedComparator {

import java.util.Comparator;

public class SpeedComparator implements Comparator<Animal> {
public int compare(Animal animal1, Animal animal2) {
return animal2.getSpeed() - animal1.getSpeed();
}

}