public class BadMethods {
/**
* Returns the integer closest to the input value.
* @param input
* @return input
rounded to the nearest int
*/
public static int round(double input) {
return (int)(input + 0.5);
}
/**
* Determines whether the input String
is a palindrome.
* A palindrome is a String
whose characters are exactly
* the same forward and backward.
* @param text
* @return true
if text
is a palindrome, otherwise false
*/
public static boolean isPalindrome(String text) {
boolean matches = true;
for(int i = 0; i < text.length(); ++i) {
if(text.charAt(i) == text.charAt(text.length() - i - 1))
matches = true;
else
matches = false;
}
return matches;
}
/**
* Finds the largest value in the input array of int
values.
* @param array
* @return largest value in array
*/
public static int largest(int[] array) {
int largest = 0;
for(int i = 0; i < array.length; ++i) {
if(array[i] > largest)
largest = array[i];
}
return largest;
}
}