Skip to content

Commit bd60e13

Browse files
authored
Fix ReverseWords class and test (TheAlgorithms#2077)
1 parent 09765b8 commit bd60e13

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/main/java/com/string/ReverseWords.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.strings;
1+
package com.string;
22

33
public class ReverseWords {
44
/**
@@ -8,7 +8,7 @@ public class ReverseWords {
88
* @return the {@code String}, converted to a string with reveresed words.
99
*/
1010

11-
public String returnReverseWords(String s) {
11+
public static String returnReverseWords(String s) {
1212
StringBuilder sb = new StringBuilder();
1313
StringBuilder word = new StringBuilder();
1414

src/test/java/com/string/ReverseWordsTest.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
import org.junit.jupiter.api.Assertions;
44
import org.junit.jupiter.api.Test;
55

6-
class ReveresWordsTest {
6+
class ReverseWordsTest extends ReverseWords {
77

88
@Test
99
void testReverseWords() {
10-
ReverseWords reverseWords = new ReverseWords();
11-
Assertions.assertEquals(true, reverseWords.returnReverseWords("this is my car"), "siht si ym rac");
12-
Assertions.assertEquals(true, reverseWords.returnReverseWords("ABC 123"), "CBA 321");
13-
10+
Assertions.assertEquals(true, returnReverseWords("this is my car").equals("siht si ym rac"), "Correct");
11+
Assertions.assertEquals(true, returnReverseWords("ABC 123").equals("CBA 321"), "Correct");
1412
}
1513
}

0 commit comments

Comments
 (0)