Skip to content
Open

quiz #34

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,18 @@

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 valueToEvaluate >= 5 && valueToEvaluate <=7;
}

public Boolean startsWith(String string, Character character) {
return null;
return string.toLowerCase().toCharArray()[0]==character.toString().toLowerCase().toCharArray()[0];
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
package com.zipcodewilmington.assessment2.part1;

import java.util.Arrays;

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

public Integer[] range(int start, int stop) {
return null;
Integer[] rangeArray = new Integer[stop - start + 1];
int counter = 0;
for (int i = start; i<=stop; i++){
rangeArray[counter] = i;
counter++;
}


return rangeArray;
}

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

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

public class WuTangConcatenator {
Integer dividend;
public WuTangConcatenator(Integer input) {
this.dividend = input;
}

public Boolean isWu() {
return null;
return dividend %3 == 0;
}

public Boolean isTang() {
return null;
return dividend % 5 ==0;
}

public Boolean isWuTang() {
return null;
return dividend % 15 == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,68 @@

public class ArrayUtility {
public Integer[] merge(Integer[] array1, Integer[] array2) {
return null;
Integer[] merged = new Integer[array1.length + array2.length];
int counter = 0;
for (int j = 0;j<array1.length;j++){
merged[counter]=array1[j];
counter++;
}
counter=0;
for (int i = array1.length;i<merged.length;i++){
merged[i] = array2[counter];
counter++;
}
return merged;
}

public Integer[] rotate(Integer[] array, Integer index) {
return null;
Integer[] holdArray = new Integer[array.length];
int firstValue;
for (int i = 0; i < index; i++) {
firstValue = array[0];
for (int j = 0; j < array.length; j++) {
if (j < array.length - 1) {
array[j] = array[j + 1];
} else {
array[j] = firstValue;
}
}
}
return array;
}

public Integer countOccurrence(Integer[] array1, Integer[] array2, Integer valueToEvaluate) {
return null;
int counter = 0;
for (Integer num : array1){
if (num == valueToEvaluate){
counter++;
}
}
for (Integer num : array2){
if (num == valueToEvaluate) {

counter++;
}
}
return counter;
}

public Integer mostCommon(Integer[] array) {
return null;
Integer result=0;
int counter = 0;
int prevCounter = 0;
for(Integer num : array){
prevCounter = counter;
counter = 0;
for (Integer currentNum :array){
if (currentNum == num){
counter++;
}
if (counter > prevCounter){
result = num;
}
}
}
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,72 @@
package com.zipcodewilmington.assessment2.part2;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

public class ListUtility {
ArrayList<Integer> theList = new ArrayList<Integer>();

public ListUtility(){
this.theList = new ArrayList<Integer>();
}
public Boolean add(int i) {
return null;
this.theList.ensureCapacity(theList.size()+1);
if (theList.size()>0) {
theList.add(theList.size() - 1, i);
} else {
theList.add(0,i);
}
return theList.contains(i);
}

public Integer size() {
return null;
return this.size();
}

public List<Integer> getUnique() {
return null;
ArrayList<Integer> resultList = new ArrayList<>();
for(Integer num : this.theList){
if (!resultList.contains(num))
{resultList.add(num);}
}
return resultList;
}

public String join() {
return null;
String result = "";
result += theList.get(0);
for (int i = 1; i < theList.size();i++){
result += ", " + theList.get(i);
}
return result;
}

public Integer mostCommon() {
return null;
Integer result=0;
int counter = 0;
int prevCounter = 0;
for(Integer num : theList){
prevCounter = counter;
counter = 0;
for (Integer currentNum :theList){
if (currentNum == num){
counter++;
}
if (counter > prevCounter){
result = num;
}
}
}
return result;
}

public Boolean contains(Integer valueToAdd) {
return null;
for (int i = 0;i<theList.size();i++){
if (theList.get(i) == valueToAdd){
return true;
}
}
return false;
}
}
14 changes: 12 additions & 2 deletions src/main/java/com/zipcodewilmington/assessment2/part2/Router.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
package com.zipcodewilmington.assessment2.part2;

import java.util.HashMap;

public class Router {
HashMap<String, String> theMap;

public Router(){
this.theMap = new HashMap<String,String>();
}
public void add(String path, String controller) {
this.theMap.put(path,controller);
}

public Integer size() {
return null;
return theMap.size();
}

public String getController(String path) {
return null;
return theMap.get(path);
}

public void update(String path, String studentController) {
theMap.put(path,studentController);
}

public void remove(String path) {
theMap.remove(path);
}
}