-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(8-kyu): kata/grasshopper-combine-strings (#520)
- Loading branch information
1 parent
c3037d9
commit 9b70f42
Showing
4 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# [Grasshopper - Combine strings](https://www.codewars.com/kata/grasshopper-combine-strings "https://www.codewars.com/kata/55f73f66d160f1f1db000059") | ||
|
||
Create a function named `combineNames` that accepts two parameters (first and last name). The function should return the | ||
full name. | ||
|
||
Example: | ||
|
||
``` | ||
combineNames("James", "Stevens"); | ||
``` | ||
|
||
returns: | ||
|
||
``` | ||
"James Stevens" | ||
``` |
5 changes: 5 additions & 0 deletions
5
kata/8-kyu/grasshopper-combine-strings/main/StringCombiner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
interface StringCombiner { | ||
static String combineNames(String first, String last) { | ||
return String.format("%s %s", first, last); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
kata/8-kyu/grasshopper-combine-strings/test/StringCombinerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class StringCombinerTest { | ||
@Test | ||
void sample() { | ||
assertEquals("James Stevens", StringCombiner.combineNames("James", "Stevens")); | ||
} | ||
} |