From 00918666ddb49c93add055e59ba2c4fd7c5b2e49 Mon Sep 17 00:00:00 2001 From: fdai7460 Date: Thu, 9 Feb 2023 19:13:43 +0100 Subject: [PATCH] 2-te Binomische Formel Funktion + Test --- src/main/java/src/TasksFrame.java | 8 ++++++++ src/test/java/src/TasksFrameTest.java | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/main/java/src/TasksFrame.java b/src/main/java/src/TasksFrame.java index 18bfa1b..b606bd4 100644 --- a/src/main/java/src/TasksFrame.java +++ b/src/main/java/src/TasksFrame.java @@ -988,6 +988,14 @@ public class TasksFrame extends JFrame { return x; } + public int bin2(int a, int b) + { + int x = 0; + x = a*a - 2*a*b + b*b; + return x; + } + + private void setupBinF() { JPanel jPanel = setupPanel("Binomisches Formel"); diff --git a/src/test/java/src/TasksFrameTest.java b/src/test/java/src/TasksFrameTest.java index 481b32b..27503d7 100644 --- a/src/test/java/src/TasksFrameTest.java +++ b/src/test/java/src/TasksFrameTest.java @@ -16,6 +16,17 @@ class TasksFrameTest { assertEquals(100,x2); } + @Test + void bin2() + { + TasksFrame tasksFrame = new TasksFrame(); + int x = tasksFrame.bin2(5,4); + assertEquals(1, x); + int x2 = tasksFrame.bin2(7,3); + assertEquals(16,x2); + } + + @Test void setupPI() { TasksFrame tasksFrame = new TasksFrame();