-
-
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(7-kyu): kata/more-than-zero (#547)
- Loading branch information
1 parent
83e622b
commit 8c7c4d7
Showing
5 changed files
with
26 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
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,4 @@ | ||
# [More than Zero?](https://www.codewars.com/kata/more-than-zero "https://www.codewars.com/kata/55a710b462afc49a540000b9") | ||
|
||
Correct this code so that it takes one argument, `x`, and returns "`x` is more than zero" if `x` is positive (and nonzero), and otherwise, | ||
returns "`x` is equal to or less than zero." In both cases, replace `x` with the actual value of `x`. |
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 MoreThanZero { | ||
static String corrections(int x) { | ||
return x + " is " + (x > 0 ? "more" : "equal to or less") + " than zero."; | ||
} | ||
} |
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,14 @@ | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class SolutionTest { | ||
@Test | ||
void sample() { | ||
assertEquals("8 is more than zero.", MoreThanZero.corrections(8)); | ||
assertEquals("1 is more than zero.", MoreThanZero.corrections(1)); | ||
assertEquals("-2 is equal to or less than zero.", MoreThanZero.corrections(-2)); | ||
assertEquals("-1 is equal to or less than zero.", MoreThanZero.corrections(-1)); | ||
assertEquals("0 is equal to or less than zero.", MoreThanZero.corrections(0)); | ||
} | ||
} |