Browse Source

Summe

remotes/origin/develop
fdai7460 2 years ago
parent
commit
7f976734d5
  1. 15
      src/main/java/src/TasksFrame.java
  2. 10
      src/test/java/src/TasksFrameTest.java

15
src/main/java/src/TasksFrame.java

@ -64,15 +64,13 @@ public class TasksFrame extends JFrame {
setupSum(); setupSum();
setupDiff();
setupSumCalc(0, 10); setupSumCalc(0, 10);
setup5ModList(1, 20); setup5ModList(1, 20);
setupLeibnizR(1000); setupLeibnizR(1000);
setupDiff();
} }
@ -175,7 +173,7 @@ public class TasksFrame extends JFrame {
return a-b; return a-b;
} }
private void setupSum() {
public void setupSum() {
JPanel jPanel = setupPanel("Summe"); JPanel jPanel = setupPanel("Summe");
JTextField a = new JTextField(); JTextField a = new JTextField();
@ -200,7 +198,8 @@ public class TasksFrame extends JFrame {
String textb = b.getText(); String textb = b.getText();
Integer val_a = Integer.valueOf(texta); Integer val_a = Integer.valueOf(texta);
Integer val_b = Integer.valueOf(textb); 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() { private void setupHelloWorld() {
JPanel jPanel = setupPanel("Hello World"); JPanel jPanel = setupPanel("Hello World");

10
src/test/java/src/TasksFrameTest.java

@ -24,6 +24,16 @@ class TasksFrameTest {
assertEquals(4, diff3); 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);
}
} }

Loading…
Cancel
Save