Skip to content

Commit 8c7c4d7

Browse files
authored
feat(7-kyu): kata/more-than-zero (#547)
1 parent 83e622b commit 8c7c4d7

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Codewars Handbook ☕️🚀
22

33
[![Views statistics +1 👀](https://img.shields.io/badge/dynamic/xml?color=success&label=views&query=//*[name()=%27text%27][3]&url=https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FParanoidUser%2Fcodewars-handbook)](https://hits.seeyoufarm.com/api/count/graph/dailyhits.svg?url=https://github.com/ParanoidUser/codewars-handbook)
4-
[![Completed kata 👌](https://img.shields.io/badge/completed%20kata-69.1%25-red.svg)](https://www.codewars.com/kata/search/java?xids=completed)
4+
[![Completed kata 👌](https://img.shields.io/badge/completed%20kata-68.9%25-red.svg)](https://www.codewars.com/kata/search/java?xids=completed)
55
[![CI pipeline 🛠](https://img.shields.io/github/actions/workflow/status/ParanoidUser/codewars-handbook/build.yml?branch=main)](https://github.com/ParanoidUser/codewars-handbook/actions/workflows/build.yml)
66
[![Quality gate 🔎](https://img.shields.io/sonar/alert_status/codewars-handbook?server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/dashboard?id=codewars-handbook)
77
[![Let's have a chat! 📞](https://img.shields.io/gitter/room/ParanoidUser/codewars-handbook?color=49c39e)](https://gitter.im/ParanoidUser/codewars-handbook)
@@ -25,7 +25,7 @@ slug.
2525

2626
| [1 kyu](/kata/1-kyu/index.md) | [2 kyu](/kata/2-kyu/index.md) | [3 kyu](/kata/3-kyu/index.md) | [4 kyu](/kata/4-kyu/index.md) | [5 kyu](/kata/5-kyu/index.md) | [6 kyu](/kata/6-kyu/index.md) | [7 kyu](/kata/7-kyu/index.md) | [8 kyu](/kata/8-kyu/index.md) | [beta](/kata/beta/index.md) | [retired](/kata/retired/index.md) |
2727
|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:---------------------------:|:---------------------------------:|
28-
| 0 | 1 | 2 | 26 | 46 | 425 | 566 | 209 | 55 | 79 |
28+
| 0 | 1 | 2 | 26 | 46 | 425 | 567 | 209 | 55 | 79 |
2929

3030
**Note:** The source code is written in Java 17 and may use language features that are incompatible
3131
with Java 8, 11.

kata/7-kyu/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@
323323
- [MOD 256 without the MOD operator](mod-256-without-the-mod-operator)
324324
- [Money, Money, Money](money-money-money)
325325
- [Monty Hall Problem](monty-hall-problem)
326+
- [More than Zero?](more-than-zero)
326327
- [Most digits](most-digits)
327328
- [Most valuable character](most-valuable-character)
328329
- [Move 10](move-10)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# [More than Zero?](https://www.codewars.com/kata/more-than-zero "https://www.codewars.com/kata/55a710b462afc49a540000b9")
2+
3+
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,
4+
returns "`x` is equal to or less than zero." In both cases, replace `x` with the actual value of `x`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface MoreThanZero {
2+
static String corrections(int x) {
3+
return x + " is " + (x > 0 ? "more" : "equal to or less") + " than zero.";
4+
}
5+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import org.junit.jupiter.api.Test;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
class SolutionTest {
6+
@Test
7+
void sample() {
8+
assertEquals("8 is more than zero.", MoreThanZero.corrections(8));
9+
assertEquals("1 is more than zero.", MoreThanZero.corrections(1));
10+
assertEquals("-2 is equal to or less than zero.", MoreThanZero.corrections(-2));
11+
assertEquals("-1 is equal to or less than zero.", MoreThanZero.corrections(-1));
12+
assertEquals("0 is equal to or less than zero.", MoreThanZero.corrections(0));
13+
}
14+
}

0 commit comments

Comments
 (0)