Bladeren bron

Merge pull request #1040 from bmkiefer/circular-buffer-ref-solution

circular-buffer: make classes and methods package private in reference solution
Sam Warner 8 jaren geleden
bovenliggende
commit
a96ca3ef69
Geen account gekoppeld aan de committers e-mail

+ 1
- 1
exercises/circular-buffer/.meta/src/reference/java/BufferIOException.java Bestand weergeven

@@ -1,4 +1,4 @@
1
-public class BufferIOException extends Exception {
1
+class BufferIOException extends Exception {
2 2
 
3 3
     BufferIOException(String message) {
4 4
         super(message);

+ 6
- 6
exercises/circular-buffer/.meta/src/reference/java/CircularBuffer.java Bestand weergeven

@@ -1,17 +1,17 @@
1 1
 import java.util.LinkedList;
2 2
 import java.util.Queue;
3 3
 
4
-public class CircularBuffer<T> {
4
+class CircularBuffer<T> {
5 5
 
6 6
     private Queue<T> buffer;
7 7
     private int capacity;
8 8
 
9
-    public CircularBuffer(int size) {
9
+    CircularBuffer(int size) {
10 10
         this.buffer = new LinkedList<>();
11 11
         this.capacity = size;
12 12
     }
13 13
 
14
-    public T read() throws BufferIOException {
14
+    T read() throws BufferIOException {
15 15
         if (this.buffer.size() == 0) {
16 16
             throw new BufferIOException("Tried to read from empty buffer");
17 17
         }
@@ -19,14 +19,14 @@ public class CircularBuffer<T> {
19 19
         return this.buffer.remove();
20 20
     }
21 21
 
22
-    public void write(T data) throws BufferIOException {
22
+    void write(T data) throws BufferIOException {
23 23
         if (this.buffer.size() == this.capacity) {
24 24
             throw new BufferIOException("Tried to write to full buffer");
25 25
         }
26 26
 
27 27
         this.buffer.add(data);
28 28
     }
29
-    public void overwrite(T data) {
29
+    void overwrite(T data) {
30 30
         if (this.buffer.size() == this.capacity) {
31 31
             this.buffer.remove();
32 32
         }
@@ -34,7 +34,7 @@ public class CircularBuffer<T> {
34 34
         this.buffer.add(data);
35 35
     }
36 36
 
37
-    public void clear() {
37
+    void clear() {
38 38
         this.buffer.clear();
39 39
     }
40 40
 }

+ 1
- 1
exercises/circular-buffer/src/main/java/BufferIOException.java Bestand weergeven

@@ -1,4 +1,4 @@
1
-public class BufferIOException extends Exception {
1
+class BufferIOException extends Exception {
2 2
 
3 3
     BufferIOException(String message) {
4 4
         super(message);