I translated it to java!
class EvenOrOdd { public static String evenOrOdd(int input) { return input % 2 == 0 ? "Even" : "Odd"; } }
even_or_odd = lambda n:'Odd' if n%2 else 'Even'- class EvenOrOdd {
- public static String evenOrOdd(int input) {
- return input % 2 == 0 ? "Even" : "Odd";
- }
- }
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @DisplayName("Test Even or Odd") class EvenOddTests { @Test @DisplayName("Even Tests") void evenTests () { testEven(0); testEven(24); testEven(620); testEven(98); testEven(22); testEven(56); } @Test @DisplayName("Odd Tests") void oddTests () { testOdd(1); testOdd(77); testOdd(947); testOdd(431); testOdd(91); testOdd(21); } void testOdd(int i) { assertEquals("Odd", EvenOrOdd.evenOrOdd(i), i + " is odd"); } void testEven(int i) { assertEquals("Even", EvenOrOdd.evenOrOdd(i), i + " is even"); } }
import codewars_test as testfrom solution import even_or_odd- import org.junit.jupiter.api.DisplayName;
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
@test.describe("Example")def test_group():@test.it("test case")def test_case():test.assert_equals(even_or_odd(0), "Even", "0 is even")test.assert_equals(even_or_odd(2), "Even", "2 is even")test.assert_equals(even_or_odd(3), "Odd", "3 is odd")test.assert_equals(even_or_odd(24), "Even", "24 is even")test.assert_equals(even_or_odd(25), "Odd", "25 is odd")test.assert_equals(even_or_odd(115), "Odd", "115 is odd")test.assert_equals(even_or_odd(98), "Even", "98 is even")- @DisplayName("Test Even or Odd")
- class EvenOddTests {
- @Test
- @DisplayName("Even Tests")
- void evenTests () {
- testEven(0);
- testEven(24);
- testEven(620);
- testEven(98);
- testEven(22);
- testEven(56);
- }
- @Test
- @DisplayName("Odd Tests")
- void oddTests () {
- testOdd(1);
- testOdd(77);
- testOdd(947);
- testOdd(431);
- testOdd(91);
- testOdd(21);
- }
- void testOdd(int i) {
- assertEquals("Odd", EvenOrOdd.evenOrOdd(i), i + " is odd");
- }
- void testEven(int i) {
- assertEquals("Even", EvenOrOdd.evenOrOdd(i), i + " is even");
- }
- }