import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertFalse; // TODO: Replace examples and use TDD by writing your own tests class CalculatorTest { private Calculator calculator = new Calculator(); @Test public void shouldBeEven() { assertTrue(calculator.isEven(2)); } @Test public void shouldBeOdd() { assertFalse(calculator.isEven(3)); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertTrue;
- import static org.junit.jupiter.api.Assertions.assertFalse;
- // TODO: Replace examples and use TDD by writing your own tests
- class CalculatorTest {
- private Calculator calculator = new Calculator();
- @Test
- public void shouldBeEven() {
Calculator calculator = new Calculator();- assertTrue(calculator.isEven(2));
- }
- @Test
- public void shouldBeOdd() {
Calculator calculator = new Calculator();- assertFalse(calculator.isEven(3));
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertFalse; // TODO: Replace examples and use TDD by writing your own tests class CalculatorTest { @Test public void shouldBeEven() { Calculator calculator = new Calculator(); assertTrue(calculator.isEven(2)); } @Test public void shouldBeOdd() { Calculator calculator = new Calculator(); assertFalse(calculator.isEven(3)); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertTrue;
- import static org.junit.jupiter.api.Assertions.assertFalse;
- // TODO: Replace examples and use TDD by writing your own tests
- class CalculatorTest {
- @Test
- public void shouldBeEven() {
- Calculator calculator = new Calculator();
- assertTrue(calculator.isEven(2));
- }
- @Test
- public void shouldBeOdd() {
- Calculator calculator = new Calculator();
- assertFalse(calculator.isEven(3));
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertTrue; // TODO: Replace examples and use TDD by writing your own tests class CalculatorTest { @Test public void shouldBeEven() { Calculator calculator = new Calculator(); assertTrue(calculator.isEven(2)); } }
- import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;- import static org.junit.jupiter.api.Assertions.assertTrue;
- // TODO: Replace examples and use TDD by writing your own tests
- class CalculatorTest {
- @Test
public void test() {- public void shouldBeEven() {
- Calculator calculator = new Calculator();
- assertTrue(calculator.isEven(2));
- }
- }
Написать алгоритм для определения является ли число чётным.
Реализовать алгоритм так, чтобы им можно было легко
пользоваться повторно (многократно).
PS: подсказка - реализуйте алгоритм
в классе Calculator в виде метода.
class Calculator {
}
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
// TODO: Replace examples and use TDD by writing your own tests
class CalculatorTest {
@Test
public void test() {
}
}