From 2c668c31c77e48f9b59e08ead6adfb15ad8b789c Mon Sep 17 00:00:00 2001 From: fdai7460 Date: Mon, 6 Feb 2023 17:11:44 +0100 Subject: [PATCH] Temperatur Umrechner --- src/main/java/src/TasksFrame.java | 6 ++++++ src/test/java/src/TasksFrameTest.java | 19 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/src/TasksFrame.java b/src/main/java/src/TasksFrame.java index 76ef362..e110e0c 100644 --- a/src/main/java/src/TasksFrame.java +++ b/src/main/java/src/TasksFrame.java @@ -720,6 +720,12 @@ public class TasksFrame extends JFrame { } + public double temperatur(double tem){ + double x=0; + x = tem + 273.15; + return x; + } + public void setupArea() { JPanel jPanel = setupPanel("Area and perimeter of a Rectangle:"); diff --git a/src/test/java/src/TasksFrameTest.java b/src/test/java/src/TasksFrameTest.java index 6ef9d85..ec25977 100644 --- a/src/test/java/src/TasksFrameTest.java +++ b/src/test/java/src/TasksFrameTest.java @@ -18,11 +18,24 @@ class TasksFrameTest { { TasksFrame tasksFrame = new TasksFrame(); int x = tasksFrame.Fakultaet(5); - assertEquals(120,x); + assertEquals(120, x, 0.01); int x2 = tasksFrame.Fakultaet(1); - assertEquals(1,x2); + assertEquals(1, x2, 0.01); int x3 = tasksFrame.Fakultaet(0); - assertEquals(0,x3); + assertEquals(0, x3, 0.01); + } + + @Test + void setupTemperatur() + { + TasksFrame tasksFrame = new TasksFrame(); + double x = tasksFrame.temperatur(-10.6); + assertEquals(262.55,x); + double x2 = tasksFrame.temperatur(8.0); + assertEquals(281.15,x2); + double x3 = tasksFrame.temperatur(0); + assertEquals(273.15,x3); + } @Test