diff --git a/src/main/java/ru/j4j/array/EqLast.java b/src/main/java/ru/j4j/array/EqLast.java new file mode 100644 index 0000000..b647a16 --- /dev/null +++ b/src/main/java/ru/j4j/array/EqLast.java @@ -0,0 +1,7 @@ +package ru.j4j.array; + +public class EqLast { + public static boolean check(int[] left, int[] right) { + return left[left.length - 1] == right[right.length - 1]; + } +} diff --git a/src/test/java/ru/j4j/array/EqLastTest.java b/src/test/java/ru/j4j/array/EqLastTest.java new file mode 100644 index 0000000..c6dcc27 --- /dev/null +++ b/src/test/java/ru/j4j/array/EqLastTest.java @@ -0,0 +1,23 @@ +package ru.j4j.array; + +import static org.assertj.core.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class EqLastTest { + @Test + public void whenEq() { + int[] left = {1, 2, 3}; + int[] right = {5, 4, 3}; + boolean result = EqLast.check(left, right); + assertThat(result).isTrue(); + } + + @Test + public void whenNotEq() { + int[] left = {1, 2, 3}; + int[] right = {3, 3, 4}; + boolean result = EqLast.check(left, right); + assertThat(result).isFalse(); + } +}