De'Jon Johnson 6 年之前
父節點
當前提交
44baf6fad0

+ 3
- 2
src/main/java/rocks/zipcode/io/quiz4/generics/GenericUtils.java 查看文件

@@ -8,11 +8,12 @@ import java.util.TreeSet;
8 8
  * @author leon on 11/12/2018.
9 9
  */
10 10
 public class GenericUtils {
11
-    public static <_ extends Comparable> Iterable<Iterable<_>> powerSet(Set<_> originalSet) {
11
+    public static <_ extends Comparable> Iterable<? extends Iterable<_>> powerSet(Set<_> originalSet) {
12 12
         return null;
13 13
     }
14 14
 
15
-    public static <_ extends Comparable> Iterable<Iterable<_>> powerSet(_... originalSet) {
15
+    public static <_ extends Comparable> Iterable<? extends Iterable<_>> powerSet(_... originalSet) {
16 16
         return powerSet(new TreeSet<>(Arrays.asList(originalSet)));
17 17
     }
18 18
 }
19
+

+ 1
- 1
src/test/java/rocks/zipcode/io/quiz4/objectorientation/palindromeobject/PalindromeObjectIsPalindromeTestNegative.java 查看文件

@@ -25,6 +25,6 @@ public class PalindromeObjectIsPalindromeTestNegative {
25 25
     }
26 26
 
27 27
     public void test(String input) {
28
-        Assert.assertTrue(new PalindromeObject(input).isPalindrome());
28
+        Assert.assertFalse(new PalindromeObject(input).isPalindrome());
29 29
     }
30 30
 }

+ 0
- 54
src/test/java/rocks/zipcode/io/quiz4/utils/MyTestClass.java 查看文件

@@ -1,54 +0,0 @@
1
-package rocks.zipcode.io.quiz4.utils;
2
-
3
-import rocks.zipcode.io.quiz4.collections.ComparableTreeSet;
4
-
5
-import java.util.*;
6
-
7
-/**
8
- * @author leon on 18/12/2018.
9
- */
10
-public class MyTestClass {
11
-
12
-    public static <E> Set<Set<E>> findPowerSet(Set<E> set) {
13
-        Set<Set<E>> ret = new TreeSet<>();
14
-        ret.add(set);
15
-        if (set.isEmpty()) {
16
-            return ret;
17
-        }
18
-        Iterator<E> it = set.iterator();
19
-        while (it.hasNext()) {
20
-            Set<E> tmp = (Set)new ComparableTreeSet(set);   //create a copy of current set
21
-            tmp.remove(it.next());              //remove current element from copy set
22
-            ret.add(tmp);                       //add the remaining set to result
23
-            ret.addAll(findPowerSet(tmp));      //recursively find subsets of copy set
24
-        }
25
-        return ret;
26
-    }
27
-
28
-    public static void main(String[] args) {
29
-        Set<Character> set = (Set)new ComparableTreeSet<Character>();
30
-        set.add('x');
31
-        set.add('y');
32
-        set.add('z');
33
-        set.add('t');
34
-        System.out.println("Input set");
35
-        printSet(set);
36
-        System.out.println("\nsub sets");
37
-        findPowerSet(set).stream().forEach(MyTestClass::printSet);
38
-    }
39
-
40
-
41
-    public static <E> void printSet(E... val) {
42
-        printSet(new TreeSet<>(Arrays.asList(val)));
43
-    }
44
-
45
-    public static <E> void printSet(Set<E> set) {
46
-        StringBuilder sb = new StringBuilder(set.size() == 0 ? "{}\n" : "{");
47
-        Iterator<E> it = set.iterator();
48
-        while (it.hasNext()) {
49
-            sb.append(it.next().toString())
50
-                    .append(it.hasNext() ? ", " : "}\n");
51
-        }
52
-        System.out.print(sb.toString());
53
-    }
54
-}