Browse Source

Merge pull request #1071 from t0dd/nix-public-access

Nix public access
FridaTveit 8 years ago
parent
commit
04fe1a91d8
No account linked to committer's email

+ 12
- 12
exercises/custom-set/.meta/src/reference/java/CustomSet.java View File

@@ -6,32 +6,32 @@ import java.util.Set;
6 6
 import java.util.function.Predicate;
7 7
 import java.util.stream.Collectors;
8 8
 
9
-public class CustomSet<T> {
9
+class CustomSet<T> {
10 10
 
11 11
     private Set<T> set;
12 12
 
13
-    public CustomSet() {
13
+    CustomSet() {
14 14
         this(Collections.emptyList());
15 15
     }
16 16
 
17
-    public CustomSet(Collection<T> data) {
17
+    CustomSet(Collection<T> data) {
18 18
         set = new HashSet<>(data.size());
19 19
         this.set.addAll(data);
20 20
     }
21 21
 
22
-    public boolean isEmpty() {
22
+    boolean isEmpty() {
23 23
         return set.isEmpty();
24 24
     }
25 25
 
26
-    public boolean contains(T element) {
26
+    boolean contains(T element) {
27 27
         return set.contains(element);
28 28
     }
29 29
 
30
-    public boolean isSubset(CustomSet<T> anotherSet) {
30
+    boolean isSubset(CustomSet<T> anotherSet) {
31 31
         return set.containsAll(anotherSet.set);
32 32
     }
33 33
 
34
-    public boolean isDisjoint(CustomSet<T> anotherSet) {
34
+    boolean isDisjoint(CustomSet<T> anotherSet) {
35 35
         if (set.isEmpty() || anotherSet.set.isEmpty()) {
36 36
             return true;
37 37
         }
@@ -40,15 +40,15 @@ public class CustomSet<T> {
40 40
                 .count() == 0;
41 41
     }
42 42
 
43
-    public boolean equals(CustomSet<T> anotherSet) {
43
+    boolean equals(CustomSet<T> anotherSet) {
44 44
         return set.equals(anotherSet.set);
45 45
     }
46 46
 
47
-    public boolean add(T element) {
47
+    boolean add(T element) {
48 48
         return set.add(element);
49 49
     }
50 50
 
51
-    public CustomSet<T> getIntersection(CustomSet<T> anotherSet) {
51
+    CustomSet<T> getIntersection(CustomSet<T> anotherSet) {
52 52
         return new CustomSet<>(
53 53
                 set.stream()
54 54
                         .filter(anotherSet.set::contains)
@@ -56,13 +56,13 @@ public class CustomSet<T> {
56 56
         );
57 57
     }
58 58
 
59
-    public CustomSet<T> getUnion(CustomSet<T> anotherSet) {
59
+    CustomSet<T> getUnion(CustomSet<T> anotherSet) {
60 60
         final Set<T> union = new HashSet<>(set);
61 61
         union.addAll(anotherSet.set);
62 62
         return new CustomSet<>(union);
63 63
     }
64 64
 
65
-    public CustomSet<T> getDifference(CustomSet<T> anotherSet) {
65
+    CustomSet<T> getDifference(CustomSet<T> anotherSet) {
66 66
         final Predicate<T> predicate = anotherSet::contains;
67 67
         return new CustomSet<>(
68 68
                 set.stream()

+ 3
- 3
exercises/food-chain/.meta/src/reference/java/FoodChain.java View File

@@ -1,6 +1,6 @@
1 1
 import java.util.stream.IntStream;
2 2
 
3
-public class FoodChain {
3
+class FoodChain {
4 4
 
5 5
     private static final String[] ANIMALS = {
6 6
         "fly",
@@ -21,11 +21,11 @@ public class FoodChain {
21 21
         "I don't know how she swallowed a cow!"
22 22
     };
23 23
 
24
-    public String verse(int verse) {
24
+    String verse(int verse) {
25 25
         return verseBeginning(verse) + verseMiddle(verse) + verseEnding(verse);
26 26
     }
27 27
 
28
-    public String verses(int startVerse, int endVerse) {
28
+    String verses(int startVerse, int endVerse) {
29 29
 
30 30
         String[] verses = new String[endVerse - startVerse + 1];
31 31
 

+ 3
- 3
exercises/hamming/.meta/src/reference/java/Hamming.java View File

@@ -1,11 +1,11 @@
1
-public class Hamming {
1
+class Hamming {
2 2
     private final int hammingDistance;
3 3
 
4
-    public Hamming(String leftStrand, String rightStrand) {
4
+    Hamming(String leftStrand, String rightStrand) {
5 5
         hammingDistance = computeHammingDistance(leftStrand, rightStrand);
6 6
     }
7 7
 
8
-    public int getHammingDistance() {
8
+    int getHammingDistance() {
9 9
         return hammingDistance;
10 10
     }
11 11
 

+ 2
- 4
exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java View File

@@ -1,8 +1,8 @@
1 1
 import java.util.Arrays;
2 2
 
3
-public class Hexadecimal {
3
+class Hexadecimal {
4 4
     private static final String HEXES = "0123456789abcdef";
5
-    public static int toDecimal(String input){
5
+    static int toDecimal(String input){
6 6
         boolean  isHex = input.matches("^[0-9a-f]+");
7 7
         if (!isHex) return 0;
8 8
         return Arrays.stream(input.split(""))
@@ -11,5 +11,3 @@ public class Hexadecimal {
11 11
 
12 12
     }
13 13
 }
14
-
15
-