From feb77f111d0fe385a3a4a7ee070cb3d2b382e247 Mon Sep 17 00:00:00 2001 From: fdai7460 Date: Thu, 2 Feb 2023 11:32:23 +0100 Subject: [PATCH] Function Mod --- src/main/java/src/TasksFrame.java | 6 ++++++ src/test/java/src/TasksFrameTest.java | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/java/src/TasksFrame.java b/src/main/java/src/TasksFrame.java index e9973d0..2170fda 100644 --- a/src/main/java/src/TasksFrame.java +++ b/src/main/java/src/TasksFrame.java @@ -79,6 +79,12 @@ public class TasksFrame extends JFrame { } + public int calcMod(int n, int x) + { + int rest = n % x; + return rest; + } + private void setupEulerschePhiFunk() { JPanel jPanel = setupPanel("Eulersche Phi Funktion"); diff --git a/src/test/java/src/TasksFrameTest.java b/src/test/java/src/TasksFrameTest.java index d31ce6b..00e5c38 100644 --- a/src/test/java/src/TasksFrameTest.java +++ b/src/test/java/src/TasksFrameTest.java @@ -91,6 +91,18 @@ class TasksFrameTest { } + @Test + void setupMod() + { + TasksFrame tasksFrame = new TasksFrame(); + int p1= tasksFrame.calcMod(5,3); + assertEquals(2,p1); + int p2 = tasksFrame.calcMod(4,2); + assertEquals(0,p2); + int p3= tasksFrame.calcMod(10,3); + assertEquals(1,p3); + } + }