Skip to content

Commit 373d7e3

Browse files
authored
Merge pull request #12 from bobocode-projects/main
Completed Sync
2 parents 12e944f + a548fac commit 373d7e3

File tree

8 files changed

+95
-13
lines changed

8 files changed

+95
-13
lines changed

2-0-data-structures-and-algorithms/pom.xml

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
6+
<dependencies>
7+
<dependency>
8+
<groupId>com.bobocode</groupId>
9+
<artifactId>java-fundamentals-util</artifactId>
10+
<version>1.0-SNAPSHOT</version>
11+
<scope>compile</scope>
12+
</dependency>
13+
</dependencies>
614

715
<parent>
816
<groupId>com.bobocode</groupId>

2-0-data-structures-and-algorithms/src/main/java/com/bobocode/linked_list/LinkedList.java

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.bobocode.linked_list;
22

3+
4+
5+
import com.bobocode.util.ExerciseNotCompletedException;
6+
37
import java.util.NoSuchElementException;
48

59
/**
@@ -18,7 +22,7 @@ public class LinkedList<T> implements List<T> {
1822
* @return a new list of elements the were passed as method parameters
1923
*/
2024
public static <T> List<T> of(T... elements) {
21-
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
25+
throw new ExerciseNotCompletedException(); // todo: implement this method
2226
}
2327

2428
/**
@@ -28,7 +32,7 @@ public static <T> List<T> of(T... elements) {
2832
*/
2933
@Override
3034
public void add(T element) {
31-
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
35+
throw new ExerciseNotCompletedException(); // todo: implement this method
3236
}
3337

3438
/**
@@ -40,7 +44,7 @@ public void add(T element) {
4044
*/
4145
@Override
4246
public void add(int index, T element) {
43-
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
47+
throw new ExerciseNotCompletedException(); // todo: implement this method
4448
}
4549

4650
/**
@@ -52,7 +56,7 @@ public void add(int index, T element) {
5256
*/
5357
@Override
5458
public void set(int index, T element) {
55-
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
59+
throw new ExerciseNotCompletedException(); // todo: implement this method
5660
}
5761

5862
/**
@@ -64,18 +68,18 @@ public void set(int index, T element) {
6468
*/
6569
@Override
6670
public T get(int index) {
67-
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
71+
throw new ExerciseNotCompletedException(); // todo: implement this method
6872
}
6973

7074
/**
7175
* Returns the first element of the list. Operation is performed in constant time O(1)
7276
*
7377
* @return the first element of the list
74-
* @throws java.util.NoSuchElementException if list is empty
78+
* @throws NoSuchElementException if list is empty
7579
*/
7680
@Override
7781
public T getFirst() {
78-
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
82+
throw new ExerciseNotCompletedException(); // todo: implement this method
7983
}
8084

8185
/**
@@ -86,7 +90,7 @@ public T getFirst() {
8690
*/
8791
@Override
8892
public T getLast() {
89-
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
93+
throw new ExerciseNotCompletedException(); // todo: implement this method
9094
}
9195

9296
/**
@@ -97,7 +101,7 @@ public T getLast() {
97101
*/
98102
@Override
99103
public void remove(int index) {
100-
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
104+
throw new ExerciseNotCompletedException(); // todo: implement this method
101105
}
102106

103107

@@ -108,7 +112,7 @@ public void remove(int index) {
108112
*/
109113
@Override
110114
public boolean contains(T element) {
111-
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
115+
throw new ExerciseNotCompletedException(); // todo: implement this method
112116
}
113117

114118
/**
@@ -118,7 +122,7 @@ public boolean contains(T element) {
118122
*/
119123
@Override
120124
public boolean isEmpty() {
121-
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
125+
throw new ExerciseNotCompletedException(); // todo: implement this method
122126
}
123127

124128
/**
@@ -128,14 +132,14 @@ public boolean isEmpty() {
128132
*/
129133
@Override
130134
public int size() {
131-
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
135+
throw new ExerciseNotCompletedException(); // todo: implement this method
132136
}
133137

134138
/**
135139
* Removes all list elements
136140
*/
137141
@Override
138142
public void clear() {
139-
throw new UnsupportedOperationException("This method is not implemented yet"); // todo: implement this method
143+
throw new ExerciseNotCompletedException(); // todo: implement this method
140144
}
141145
}

3-0-java-core/pom.xml

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
6+
<dependencies>
7+
<dependency>
8+
<groupId>com.bobocode</groupId>
9+
<artifactId>java-fundamentals-util</artifactId>
10+
<version>1.0-SNAPSHOT</version>
11+
<scope>compile</scope>
12+
</dependency>
13+
</dependencies>
614

715
<parent>
816
<groupId>com.bobocode</groupId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.bobocode.file_reader;
2+
3+
import com.bobocode.util.ExerciseNotCompletedException;
4+
5+
/**
6+
* {@link FileReaders} provides an API that allow to read whole file into a {@link String} by file name.
7+
*/
8+
public class FileReaders {
9+
10+
/**
11+
* Returns a {@link String} that contains whole text from the file specified by name.
12+
*
13+
* @param fileName a name of a text file
14+
* @return string that holds whole file content
15+
*/
16+
public static String readWholeFile(String fileName) {
17+
throw new ExerciseNotCompletedException(); //todo
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.bobocode.file_reader;
2+
3+
import com.bobocode.file_reader.FileReaders;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
8+
9+
public class FileReadersTest {
10+
11+
@Test
12+
void testReadWholeFileOnEmptyFile() {
13+
String fileContent = FileReaders.readWholeFile("empty.txt");
14+
15+
assertEquals("", fileContent);
16+
17+
}
18+
19+
@Test
20+
void testReadWholeFileOnFileWithEmptyLines() {
21+
String fileContent = FileReaders.readWholeFile("lines.txt");
22+
23+
assertEquals("Hey!\n" +
24+
"\n" +
25+
"What's up?\n" +
26+
"\n" +
27+
"Hi!", fileContent);
28+
}
29+
30+
@Test
31+
void testReadWholeFile() {
32+
String fileContent = FileReaders.readWholeFile("simple.txt");
33+
34+
assertEquals("Hello!\n" + "It's a test file.", fileContent);
35+
}
36+
}

3-0-java-core/src/test/resources/empty.txt

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Hey!
2+
3+
What's up?
4+
5+
Hi!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Hello!
2+
It's a test file.

0 commit comments

Comments
 (0)