Class Utilities

java.lang.Object
sysImplementation.Utilities

public class Utilities
extends java.lang.Object
  • Constructor Summary

    Constructors 
    Constructor Description
    Utilities()  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String addDelimiter​(java.lang.String str, char delimeter)
    Returns a string where characters are separated by the specified delimeter character.
    static java.lang.String getDigits​(java.lang.String str)
    Returns a string with the digits (if any) present in the str parameter.
    static java.util.ArrayList<java.lang.Integer> getListRowIndices​(int[][] array, int rowLength)
    This method returns an ArrayList with the indices of rows of the two-dimensional having a length that corresponds to rowLength.
    static int getSumEven​(int[] array)
    Returns the sum of even values (if any) present in the array parameter.
    static void replaceCharacter​(char[] array, char target, char replacement)
    Replaces the target character in the array with the specified replacement.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • addDelimiter

      public static java.lang.String addDelimiter​(java.lang.String str, char delimeter)
      Returns a string where characters are separated by the specified delimeter character. A string with a single character will not have a delimeter added. The space character is consider a character (similar to character 'A'). You can assume str will never be the empty string. You may not use an auxiliary method in order to implement this method. Your implementation must be recursive and you may not use any loop construct. Note: In java given two characters a and b, a + b will not create a string. To create a string, append a to the empty string and the result to b. From the String class, the only methods you can use are length(), isEmpty(), charAt() and substring. Do not use ++ or -- in any recursive call argument. It may lead to an infinite recursion. For example, use index + 1, instead of index++.
      Parameters:
      str -
      delimeter -
      Returns:
      String with characters separated by delimiter or the original str if the string has a single character
    • getDigits

      public static java.lang.String getDigits​(java.lang.String str)
      Returns a string with the digits (if any) present in the str parameter. You can assume str will never be null. You can use Character.isDigit() to determine whether a character is a digit. You may not use an auxiliary method in order to implement this method. Your implementation must be recursive and you may not use any loop construct. From the String class, the only methods you can use are length(), isEmpty(), charAt() and substring. Do not use ++ or -- in any recursive call argument. It may lead to an infinite recursion. For example, use index + 1, instead of index++.
      Parameters:
      str -
      Returns:
      String with digits or empty string
    • replaceCharacter

      public static void replaceCharacter​(char[] array, char target, char replacement)
      Replaces the target character in the array with the specified replacement. You can assume the array parameter will not be null. You may only use one auxiliary method. Your implementation must be recursive and you may not use any loop construct. Do not use ++ or -- in any recursive call argument. For example, use index + 1, instead of index++.
      Parameters:
      array -
      target -
      replacement -
    • getSumEven

      public static int getSumEven​(int[] array)
      Returns the sum of even values (if any) present in the array parameter. You can assume array is not null. You may only use one auxiliary function. Your implementation must be recursive and you may not use any loop construct. Do not use ++ or -- in any recursive call argument. It may lead to an infinite recursion. For example, use index + 1, instead of index++.
      Parameters:
      array -
      Returns:
      Sum of even values
    • getListRowIndices

      public static java.util.ArrayList<java.lang.Integer> getListRowIndices​(int[][] array, int rowLength)
      This method returns an ArrayList with the indices of rows of the two-dimensional having a length that corresponds to rowLength. You may only use one auxiliary method. The method should create an ArrayList that is passed to the auxiliary in order to place the indices (if any). If no indices are found, an empty (size of 0) ArrayList will be returned. You can assume the array parameter will not be null and every row of the two-dimensional array has an array with a size of at least 0. Your implementation must be recursive and you may not use any loop construct. Do not use ++ or -- in any recursive call argument. It may lead to an infinite recursion. For example, use index + 1, instead of index++.
      Parameters:
      array -
      rowLength -
      Returns:
      ArrayList