Przeglądaj źródła

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

Nix public access
FridaTveit 8 lat temu
rodzic
commit
04fe1a91d8
Brak konta powiązanego z e-mailem autora

+ 12
- 12
exercises/custom-set/.meta/src/reference/java/CustomSet.java Wyświetl plik

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

+ 3
- 3
exercises/food-chain/.meta/src/reference/java/FoodChain.java Wyświetl plik

1
 import java.util.stream.IntStream;
1
 import java.util.stream.IntStream;
2
 
2
 
3
-public class FoodChain {
3
+class FoodChain {
4
 
4
 
5
     private static final String[] ANIMALS = {
5
     private static final String[] ANIMALS = {
6
         "fly",
6
         "fly",
21
         "I don't know how she swallowed a cow!"
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
         return verseBeginning(verse) + verseMiddle(verse) + verseEnding(verse);
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
         String[] verses = new String[endVerse - startVerse + 1];
30
         String[] verses = new String[endVerse - startVerse + 1];
31
 
31
 

+ 3
- 3
exercises/hamming/.meta/src/reference/java/Hamming.java Wyświetl plik

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

+ 2
- 4
exercises/hexadecimal/.meta/src/reference/java/Hexadecimal.java Wyświetl plik

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