瀏覽代碼

remove public access modifiers on ref solution and initial stub exception for circular buffer

Brandon Kiefer 8 年之前
父節點
當前提交
e43de6f939

+ 1
- 1
exercises/circular-buffer/.meta/src/reference/java/BufferIOException.java 查看文件

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

+ 6
- 6
exercises/circular-buffer/.meta/src/reference/java/CircularBuffer.java 查看文件

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

+ 1
- 1
exercises/circular-buffer/src/main/java/BufferIOException.java 查看文件

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