Nathan Hall 5 年之前
父節點
當前提交
f0cc204c00

+ 24
- 2
src/main/java/rocks/zipcode/io/quiz4/fundamentals/PalindromeEvaluator.java 查看文件

@@ -1,18 +1,40 @@
1 1
 package rocks.zipcode.io.quiz4.fundamentals;
2 2
 
3
+
4
+import com.sun.deploy.util.StringUtils;
5
+
6
+import java.util.ArrayList;
7
+import java.util.List;
8
+
3 9
 /**
4 10
  * @author leon on 18/12/2018.
5 11
  */
6 12
 public class PalindromeEvaluator {
7 13
     public static String[] getAllPalindromes(String string) {
14
+        char[] arr = string.toCharArray();
15
+        for (char c : arr){
16
+            System.out.println(c);
17
+        }
8 18
         return null;
9 19
     }
10 20
 
11 21
     public static Boolean isPalindrome(String string) {
12
-        return null;
22
+        string.toLowerCase();
23
+        for (int i = 0; i < string.length()/2; i++) {
24
+            if (string.charAt(string.length()-1 - i) != string.charAt(i)){
25
+                return false;
26
+            }
27
+
28
+        }
29
+
30
+        return true;
13 31
     }
14 32
 
15 33
     public static String reverseString(String string) {
16
-        return null;
34
+        String newStr = "";
35
+        for (int i = 1; i <= string.length(); i++){
36
+            newStr += string.substring(string.length() - i , string.length() - i + 1);
37
+        }
38
+        return newStr;
17 39
     }
18 40
 }

+ 1
- 0
src/main/java/rocks/zipcode/io/quiz4/fundamentals/StringEvaluator.java 查看文件

@@ -5,6 +5,7 @@ package rocks.zipcode.io.quiz4.fundamentals;
5 5
  */
6 6
 public class StringEvaluator {
7 7
     public static String[] getAllPrefixes(String string) {
8
+
8 9
         return null;
9 10
     }
10 11