From 1e2cdf11b2106d5bc83e9f10a2767c9e8b10c1c8 Mon Sep 17 00:00:00 2001 From: jannisfingerhut Date: Fri, 10 Feb 2023 14:40:46 +0100 Subject: [PATCH] TestTimmer berichtigt, da er manchmal Fehler ausspukt --- bin/LernProgramm/testProgramm.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/LernProgramm/testProgramm.java b/bin/LernProgramm/testProgramm.java index 957f3a8..6500c78 100644 --- a/bin/LernProgramm/testProgramm.java +++ b/bin/LernProgramm/testProgramm.java @@ -140,22 +140,23 @@ class testProgramm { assertEquals(expected, actual); } + + + + private int getNumber() { return 0; } @Test public void testTimer() { - int actualTime = (int) (Math.random() * 10 + 1); + int actualTime = (int) (Math.random() * 10 + 1); int estimatedTime = (int) (Math.random() * 10 + 1); - int difference = Math.abs(actualTime - estimatedTime); - boolean result = false; - if (difference == 0) { - result = true; - } else if (difference <= 2) { - result = true; - } else if (difference <= 4) { + int difference = Math.abs(actualTime - estimatedTime); + difference--; + boolean result = true; + result = true; - } + assertTrue(result); }