From 1e1b628443d486c09d75ea5b20412900afbdc382 Mon Sep 17 00:00:00 2001 From: fdai6040 Date: Thu, 2 Feb 2023 13:55:48 +0100 Subject: [PATCH 1/2] Round Sum Test --- src/main/java/src/TasksFrame.java | 4 ++-- src/test/java/src/TasksFrameTest.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/src/TasksFrame.java b/src/main/java/src/TasksFrame.java index 39b80f9..0c367fd 100644 --- a/src/main/java/src/TasksFrame.java +++ b/src/main/java/src/TasksFrame.java @@ -130,11 +130,11 @@ public class TasksFrame extends JFrame { 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) { return n + 10 - n % 10; } diff --git a/src/test/java/src/TasksFrameTest.java b/src/test/java/src/TasksFrameTest.java index ea4a96b..ca296e1 100644 --- a/src/test/java/src/TasksFrameTest.java +++ b/src/test/java/src/TasksFrameTest.java @@ -126,6 +126,16 @@ class TasksFrameTest { 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); + } } From b94c310149ba2d99a4c1b6dcbe3fe6c1da04554c Mon Sep 17 00:00:00 2001 From: fdai6040 Date: Thu, 2 Feb 2023 14:01:11 +0100 Subject: [PATCH 2/2] Round10 Function Test --- 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 ca296e1..4af998f 100644 --- a/src/test/java/src/TasksFrameTest.java +++ b/src/test/java/src/TasksFrameTest.java @@ -136,6 +136,17 @@ class TasksFrameTest { int c = tasksFrame.roundSum(13, 9, 26); assertEquals(50, c); } + + @Test + void test_round10(){ + TasksFrame tasksFrame = new TasksFrame(); + int a = tasksFrame.round10(15); + assertEquals(20, a); + int b = tasksFrame.round10(56); + assertEquals(60, b); + int c = tasksFrame.round10(12); + assertEquals(10, c); + } }