Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c42577d

Browse files
Kyu 8 | Are you Playing Banjo?
1 parent 08cae95 commit c42577d

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

‎src/main/java/kyu8/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Kata Found realized
2424

2525
- [All Star Code Challenge #18](allStarCodeChallenge18)
2626

27+
- [Are You Playing Banjo?](areYouPlayingBanjo)
28+
2729
- [Find Nearest square number](findNearestSquareNumber)
2830

2931

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package kyu8.areYouPlayingBanjo;
2+
3+
public class Banjo {
4+
public static String areYouPlayingBanjo(String name) {
5+
if (name.toLowerCase().charAt(0) == 'r') {
6+
return name + " plays banjo";
7+
} else {
8+
return name + " does not play banjo";
9+
}
10+
}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Are You Playing Banjo?
2+
3+
Create a function which answers the question "Are you playing banjo?".
4+
If your name starts with the letter "R" or lower case "r", you are playing banjo!
5+
6+
The function takes a name as its only argument, and returns one of the following strings:
7+
8+
```java
9+
name + " plays banjo"
10+
name + " does not play banjo"
11+
```
12+
13+
Names given are always valid strings.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package kyu8.areYouPlayingBanjo;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
7+
public class testBanjo {
8+
@Test
9+
public void PeopleThatPlayBanjo() {
10+
assertEquals( "Martin does not play banjo", Banjo.areYouPlayingBanjo("Martin"));
11+
assertEquals( "Rikke plays banjo", Banjo.areYouPlayingBanjo("Rikke"));
12+
assertEquals( "rolf plays banjo", Banjo.areYouPlayingBanjo("rolf"));
13+
assertEquals( "bravo does not play banjo", Banjo.areYouPlayingBanjo("bravo"));
14+
}
15+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /