From 0f463ab7a38039258117ce7b2ce8c6483e6a9fe4 Mon Sep 17 00:00:00 2001 From: "d.kapustin" Date: Wed, 27 Sep 2023 16:13:11 +0300 Subject: [PATCH] =?UTF-8?q?6.4.1.=20=D0=A1=D1=80=D0=B0=D0=B2=D0=BD=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D1=8D=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D1=8B=20?= =?UTF-8?q?=D0=B4=D0=B2=D1=83=D1=85=20=D0=BC=D0=B0=D1=81=D1=81=D0=B8=D0=B2?= =?UTF-8?q?=D0=BE=D0=B2;=20https://job4j.ru/profile/exercise/2/task-view/1?= =?UTF-8?q?00?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ru/j4j/array/EqLast.java | 7 +++++++ src/test/java/ru/j4j/array/EqLastTest.java | 23 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/main/java/ru/j4j/array/EqLast.java create mode 100644 src/test/java/ru/j4j/array/EqLastTest.java 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(); + } +}