From 7f976734d523fd41f0587c520e4e42e55afccc50 Mon Sep 17 00:00:00 2001 From: fdai7460 Date: Wed, 1 Feb 2023 11:55:53 +0100 Subject: [PATCH] Summe --- src/main/java/src/TasksFrame.java | 15 +++++++++------ src/test/java/src/TasksFrameTest.java | 10 ++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/java/src/TasksFrame.java b/src/main/java/src/TasksFrame.java index 0eb67ad..2dd3d0f 100644 --- a/src/main/java/src/TasksFrame.java +++ b/src/main/java/src/TasksFrame.java @@ -64,15 +64,13 @@ public class TasksFrame extends JFrame { setupSum(); + setupDiff(); + setupSumCalc(0, 10); setup5ModList(1, 20); setupLeibnizR(1000); - - setupDiff(); - - } @@ -175,7 +173,7 @@ public class TasksFrame extends JFrame { return a-b; } - private void setupSum() { + public void setupSum() { JPanel jPanel = setupPanel("Summe"); JTextField a = new JTextField(); @@ -200,7 +198,8 @@ public class TasksFrame extends JFrame { String textb = b.getText(); Integer val_a = Integer.valueOf(texta); Integer val_b = Integer.valueOf(textb); - result.setText(String.valueOf(val_a+val_b)); + int res = calcSumm(val_a, val_b); + result.setText(String.valueOf(res)); } }); @@ -212,6 +211,10 @@ public class TasksFrame extends JFrame { } + public int calcSumm(int a, int b) { + return a+b; + } + private void setupHelloWorld() { JPanel jPanel = setupPanel("Hello World"); diff --git a/src/test/java/src/TasksFrameTest.java b/src/test/java/src/TasksFrameTest.java index 6be620c..146396e 100644 --- a/src/test/java/src/TasksFrameTest.java +++ b/src/test/java/src/TasksFrameTest.java @@ -24,6 +24,16 @@ class TasksFrameTest { assertEquals(4, diff3); } + @Test + void setupSumm(){ + TasksFrame frame = new TasksFrame(); + int sum1 = frame.calcSumm(23, 11); + assertEquals(34, sum1); + int sum2 = frame.calcSumm(0,0); + assertEquals(0, sum2); + int sum3= frame.calcSumm(-1,-9); + assertEquals(-10,sum3); + } }