Browse Source

Round Sum Test

remotes/origin/develop
fdai6040 2 years ago
parent
commit
1e1b628443
  1. 4
      src/main/java/src/TasksFrame.java
  2. 10
      src/test/java/src/TasksFrameTest.java

4
src/main/java/src/TasksFrame.java

@ -130,11 +130,11 @@ public class TasksFrame extends JFrame {
public int roundSum(int a, int b, int c) { public int roundSum(int a, int b, int c) {
return runde10(a) + runde10(b) + runde10(c);
return round10(a) + round10(b) + round10(c);
} }
public int runde10(int n) {
public int round10(int n) {
if (n % 10 >= 5) { if (n % 10 >= 5) {
return n + 10 - n % 10; return n + 10 - n % 10;
} }

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

@ -126,6 +126,16 @@ class TasksFrameTest {
assertEquals(70, c); assertEquals(70, c);
} }
@Test
void test_roundSum(){
TasksFrame tasksFrame = new TasksFrame();
int a = tasksFrame.roundSum(15, 21, 12);
assertEquals(50, a);
int b = tasksFrame.roundSum(48, 25, 17);
assertEquals(100, b);
int c = tasksFrame.roundSum(13, 9, 26);
assertEquals(50, c);
}
} }

Loading…
Cancel
Save