Skip to content

Commit 3e71a5b

Browse files
committed
Changes suggested by kahgoh were made
1 parent fbf5c8d commit 3e71a5b

File tree

4 files changed

+165
-274
lines changed

4 files changed

+165
-274
lines changed

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@
18761876
"uuid": "81177978-2ed3-47c2-a6a0-fef316d94c0b",
18771877
"practices": [],
18781878
"prerequisites": [],
1879-
"difficulty": 1
1879+
"difficulty": 4
18801880
}
18811881
],
18821882
"foregone": [

exercises/practice/paasio/.meta/src/reference/java/Paasio.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ public class Paasio implements Closeable {
1010
private final InputStream inputStream;
1111
private final OutputStream outputStream;
1212

13+
14+
public InputStream getInputStream() {
15+
return inputStream;
16+
}
17+
18+
public OutputStream getOutputStream() {
19+
return outputStream;
20+
}
21+
1322
public Paasio(InputStream inputStream, OutputStream outputStream) {
1423
this.inputStream = inputStream;
1524
this.outputStream = outputStream;

exercises/practice/paasio/src/main/java/Paasio.java

Lines changed: 16 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -10,101 +10,59 @@ public class Paasio implements Closeable {
1010
private final InputStream inputStream;
1111
private final OutputStream outputStream;
1212

13+
public InputStream getInputStream() {
14+
return inputStream;
15+
}
16+
17+
public OutputStream getOutputStream() {
18+
return outputStream;
19+
}
20+
1321
public Paasio(InputStream inputStream, OutputStream outputStream) {
1422
this.inputStream = inputStream;
1523
this.outputStream = outputStream;
1624
}
1725

1826
public int read() throws IOException {
19-
int byteData = inputStream.read();
20-
if (byteData != -1) {
21-
bytesRead += 1;
22-
readOperationCount++;
23-
}
24-
return byteData;
27+
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
2528
}
2629

2730
public int read(byte[] b) throws IOException {
28-
29-
int totalBytesRead = inputStream.read(b);
30-
if (totalBytesRead != -1) {
31-
bytesRead += totalBytesRead;
32-
readOperationCount++;
33-
}
34-
return totalBytesRead;
31+
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
3532

3633
}
3734

3835
public int read(byte[] b, int off, int len) throws IOException {
3936

40-
int bytesReadIntoBuffer = inputStream.read(b, off, len);
41-
42-
if (bytesReadIntoBuffer != -1) {
43-
bytesRead += bytesReadIntoBuffer;
44-
readOperationCount++;
45-
}
46-
return bytesReadIntoBuffer;
47-
37+
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
4838

4939
}
5040

5141
public byte[] readAllBytes() throws IOException {
5242

53-
byte[] allData = this.inputStream.readAllBytes();
54-
55-
if (allData.length > 0) {
56-
readOperationCount++;
57-
bytesRead += allData.length;
58-
}
59-
return allData;
43+
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
6044

6145
}
6246

6347
public byte[] readNBytes(int len) throws IOException {
6448

65-
byte[] allData = this.inputStream.readNBytes(len);
66-
if (allData.length > 0) {
67-
readOperationCount++;
68-
bytesRead += allData.length;
69-
}
70-
return allData;
49+
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
7150
}
7251

7352
public void write(int b) throws IOException {
7453

75-
try {
76-
this.outputStream.write(b);
77-
writeOperationCount++;
78-
bytesWritten++;
79-
80-
} catch (IOException ioException) {
81-
ioException.printStackTrace();
82-
}
54+
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
8355

8456
}
8557

8658
public void write(byte[] b) throws IOException {
87-
try {
8859

89-
this.outputStream.write(b);
90-
writeOperationCount++;
91-
bytesWritten += b.length;
60+
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
9261

93-
94-
} catch (IOException ioException) {
95-
ioException.printStackTrace();
96-
}
9762
}
9863

9964
public void write(byte[] b, int off, int len) throws IOException {
100-
try {
101-
this.outputStream.write(b, off, len);
102-
writeOperationCount++;
103-
bytesWritten += len;
104-
105-
} catch (IOException ioException) {
106-
ioException.printStackTrace();
107-
}
65+
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
10866
}
10967

11068
public long getBytesRead() {

0 commit comments

Comments
 (0)