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 2890d71

Browse files
Kyu 8 | 101 Dalmatians - squash the bugs, not the dogs!
1 parent b77a8ea commit 2890d71

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# 101 Dalmatians - squash the bugs, not the dogs!
2+
3+
Your friend has been out shopping for puppies (what a time to be alive!)... He arrives back with multiple dogs, and you
4+
simply do not know how to respond!
5+
6+
By repairing the function provided, you will find out exactly how you should respond, depending on the number of dogs he
7+
has.
8+
9+
The number of dogs will always be a number and there will always be at least 1 dog.
10+
11+
```
12+
Good Luck!
13+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package kyu8.dalmatians101SquashTheBugs;
2+
3+
public class ZywOo {
4+
public static String howManyDalmatians(int number) {
5+
String[] dogs = {"Hardly any", "More than a handful!", "Woah that's a lot of dogs!", "101 DALMATIANS!!!"};
6+
return number <= 10 ? dogs[0] : number <= 50 ? dogs[1] : number == 101 ? dogs[3] : dogs[2];
7+
}
8+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package kyu8.dalmatians101SquashTheBugs;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
7+
public class testZywOo {
8+
@Test
9+
public void basicTests() {
10+
assertEquals("More than a handful!", ZywOo.howManyDalmatians(26));
11+
assertEquals("Hardly any", ZywOo.howManyDalmatians(8));
12+
assertEquals("More than a handful!", ZywOo.howManyDalmatians(14));
13+
assertEquals("Woah that's a lot of dogs!", ZywOo.howManyDalmatians(80));
14+
assertEquals("Woah that's a lot of dogs!", ZywOo.howManyDalmatians(100));
15+
assertEquals("101 DALMATIANS!!!", ZywOo.howManyDalmatians(101));
16+
}
17+
}

0 commit comments

Comments
(0)

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