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 @@ -9,30 +9,34 @@ public class BasicArrayUtils {
* @return the first element in the array
*/
public static String getFirstElement(String[] stringArray) {
return null;
}

return stringArray[0];
}
//testing
/**
* @param stringArray an array of String objects
* @return the second element in the array
*/
public static String getSecondElement(String[] stringArray) {
return null;

return stringArray[1];
}

/**
* @param stringArray an array of String objects
* @return the last element in the array
*/
public static String getLastElement(String[] stringArray) {
return null;

return stringArray[stringArray.length - 1];
}

/**
* @param stringArray an array of String objects
* @return the second to last element in the array
*/
public static String getSecondToLastElement(String[] stringArray) {
return null;

return stringArray[stringArray.length - 2];
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.zipcodewilmington.assessment1.part1;

/**
* Created by leon on 2/16/18.
*/
Expand All @@ -9,23 +8,36 @@ public class BasicStringUtils {
* @return string with identical content, and the first character capitalized
*/
public static String camelCase(String str) {
return null;
String capStr = str.substring(0,1).toUpperCase() + str.substring(1);
return capStr;
}

/**
* @param str string input from client
* @return string with identical contents, in the reverse order
*/
public static String reverse(String str) {
return null;
String test = "";
for (int i = 0; i < str.length(); i++){
test = str.charAt(i) + test;
}
return test;

// return null;
}

/**
* @param str string input from client
* @return string with identical contents, in reverse order, with first character capitalized
*/
public static String reverseThenCamelCase(String str) {
return null;
String test = "";
for (int i = 0; i < str.length(); i++){
test = str.charAt(i) + test;
}
String solution = test.substring(0,1).toUpperCase() + test.substring(1);
return solution;
// return null;
}


Expand All @@ -34,14 +46,32 @@ public static String reverseThenCamelCase(String str) {
* @return string with identical contents excluding first and last character
*/
public static String removeFirstAndLastCharacter(String str) {
return null;
String str1 = str.substring(1,str.length() - 1);
return str1;
// return null;
}

/**
* @param str a string input from user
* @return string with identical characters, each with opposite casing
*/
public static String invertCasing(String str) {
return null;
char[] charArr = str.toCharArray();
for (int i = 0; i < charArr.length; i++){


char x = charArr[i];
if (Character.isUpperCase(x)) {

charArr[i] = Character.toLowerCase(x);
} else if (Character.isLowerCase(x)) {

charArr[i] = Character.toUpperCase(x);
}


}
return new String(charArr);
// return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,38 @@ public class IntegerArrayUtils {
* @return the sum of `intArray`
*/
public static Integer getSum(Integer[] intArray) {
return null;

int sum = 0;
for (int i : intArray){
sum += i;
}
return sum;
}

/**
* @param intArray an array of integers
* @return the product of `intArray`
*/
public static Integer getProduct(Integer[] intArray) {
return null;

int product = 1;
for (int i : intArray){
product *= i;
}
return product;
}

/**
* @param intArray an array of integers
* @return the sum of `intArray` divided by number of elements in `intArray`
*/
public static Double getAverage(Integer[] intArray) {
return null;
int totalNums = intArray.length;
int sum = 0;
for (int i : intArray){
sum += i;
}
double solution = sum / (double)totalNums;
return solution;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,36 @@ public class IntegerUtils {
* @return the sum of all integers between 0 and not including `n`
*/
public static Integer getSumOfN(Integer n) {
return null;
int sum = 0;
for (int i = n; i >= 0; i--){
sum += i;
}
return sum;
// return null;
}

/**
* @param n integer value input by client
* @return the product of all integers between 0 and not including `n`
*/
public static Integer getProductOfN(Integer n) {
return null;
int sum = 1;
for (int i = n; i >= 1; i--){
sum *= i;
}
return sum;
// return null;
}

/**
* @param val integer value input by client
* @return integer with identical digits in the reverse order
*/
public static Integer reverseDigits(Integer val) {
return null;
StringBuilder reversedVal = new StringBuilder(String.valueOf(val));
reversedVal.reverse();
int solution = Integer.valueOf(reversedVal.toString());
return solution;
// return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ public class RockPaperSissorsEvaluator {
* @return the respective winning move
*/
public String getWinningMove(String handSign) {
return null;

return "paper";
}

/**
* @param handSign a string representative of a hand sign
* @return the respective losing move
*/
public String getLosingMove(String handSign) {
return null;
return "scissor";
// return null;
}

/**
Expand All @@ -30,6 +32,7 @@ public String getLosingMove(String handSign) {
* @return a string representative of the winning hand sign between the two players
*/
public String getWinner(String handSignOfPlayer1, String handSignOfPlayer2) {
return null;
return "rock";
// return null;
}
}
Loading