From 716331f19bb76dd16c38dd7d251401bb8c4c8076 Mon Sep 17 00:00:00 2001 From: fdai6040 Date: Thu, 2 Feb 2023 12:02:10 +0100 Subject: [PATCH 1/2] Test Quersumme --- src/test/java/src/TasksFrameTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/src/TasksFrameTest.java b/src/test/java/src/TasksFrameTest.java index 00e5c38..8da67c4 100644 --- a/src/test/java/src/TasksFrameTest.java +++ b/src/test/java/src/TasksFrameTest.java @@ -103,6 +103,17 @@ class TasksFrameTest { assertEquals(1,p3); } + @Test + void test_quer(){ + TasksFrame tasksFrame = new TasksFrame(); + int q = tasksFrame.quer(15); + assertEquals(6, q); + int q2 = tasksFrame.quer(23); + assertEquals(5, q2); + int q3 = tasksFrame.quer(235); + assertEquals(10, q3); + + } } From ea085e0631d73cb99ad9918021578bff8b0285f0 Mon Sep 17 00:00:00 2001 From: fdai6040 Date: Thu, 2 Feb 2023 12:39:26 +0100 Subject: [PATCH 2/2] kgV Function added --- src/main/java/src/TasksFrame.java | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/main/java/src/TasksFrame.java b/src/main/java/src/TasksFrame.java index ed4f91f..f01a0b0 100644 --- a/src/main/java/src/TasksFrame.java +++ b/src/main/java/src/TasksFrame.java @@ -79,6 +79,52 @@ public class TasksFrame extends JFrame { setupQuersumme(); + setupKgV(); + + } + + private void setupKgV() { + JPanel jPanel = setupPanel("kgV"); + + JButton button = new JButton("kgV"); + button.setVisible(true); + button.setBounds(10, 65, 100, 30); + + JTextField a = new JTextField(); + a.setBounds(10, 40, 30, 20); + a.setVisible(true); + + JTextField b = new JTextField(); + b.setBounds(50, 40, 30, 20); + b.setVisible(true); + + JLabel jLabel = new JLabel(); + jLabel.setVisible(true); + jLabel.setBounds(10,90,60,30); + + jPanel.add(button); + jPanel.add(a); + jPanel.add(b); + jPanel.add(jLabel); + + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String texta = a.getText(); + String textb = b.getText(); + Integer val_a = Integer.valueOf(texta); + Integer val_b = Integer.valueOf(textb); + int res = kgV(val_a, val_b); + jLabel.setText(String.valueOf(res)); + } + }); + + + } + + public int kgV(int a, int b) { + int kgV= (a*b)/ggt(a,b); + return kgV; } private void setupQuersumme() {