@@ -4,8 +4,10 @@ | |||
<exclude-output /> | |||
<content url="file://$MODULE_DIR$"> | |||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | |||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" /> | |||
</content> | |||
<orderEntry type="inheritedJdk" /> | |||
<orderEntry type="sourceFolder" forTests="false" /> | |||
<orderEntry type="library" name="junit.jupiter" level="project" /> | |||
</component> | |||
</module> |
@@ -0,0 +1,42 @@ | |||
package Prak1; | |||
public class zahlenfilterNeu { | |||
public static void main(String[] args) { | |||
printNumbers(); | |||
} | |||
private static void printNumbers(){ | |||
int grenze = 20; | |||
int i; | |||
for (i=1; i<=grenze; i++){ | |||
if(filter(i)){ | |||
System.out.println(i); | |||
} | |||
} | |||
} | |||
public static boolean filter(int i){ | |||
return !(durch5teilbar(i) || endetMit9(i) || summeDurch3(i)); | |||
} | |||
public static boolean durch5teilbar(int i) { | |||
if (i % 5 == 0) { | |||
return true; | |||
} else { | |||
return false; | |||
} | |||
} | |||
public static boolean endetMit9(int i) { | |||
if (i % 10 == 9) { | |||
return true; | |||
} else { | |||
return false; | |||
} | |||
} | |||
public static boolean summeDurch3(int i) { | |||
int x = i + (i - 1); | |||
if (x % 3 == 0) { | |||
return true; | |||
} else { | |||
return false; | |||
} | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
package Prak1; | |||
import org.junit.jupiter.api.Test; | |||
import static org.junit.jupiter.api.Assertions.*; | |||
class TriangleCheckerTest { | |||
@Test | |||
void checkTriangle_Normal () { | |||
assertEquals(TriangleChecker.TriangleType.NORMAL, TriangleChecker.checkTriangle(15, 12, 22)); | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
package Prak1; | |||
import org.junit.jupiter.api.Test; | |||
import static org.junit.jupiter.api.Assertions.*; | |||
class zahlenfilterNeuTest { | |||
@Test | |||
void filter() { | |||
assertTrue(zahlenfilterNeu.filter(3)); | |||
assertTrue(zahlenfilterNeu.filter(7)); | |||
assertFalse(zahlenfilterNeu.filter(10)); | |||
} | |||
@Test | |||
void durch5teilbar() { | |||
assertTrue(zahlenfilterNeu.durch5teilbar(15)); | |||
assertTrue(zahlenfilterNeu.durch5teilbar(20)); | |||
assertFalse(zahlenfilterNeu.durch5teilbar(27)); | |||
} | |||
@Test | |||
void endetMit9() { | |||
assertTrue(zahlenfilterNeu.endetMit9(9)); | |||
assertTrue(zahlenfilterNeu.endetMit9(19)); | |||
assertFalse(zahlenfilterNeu.endetMit9(15)); | |||
} | |||
@Test | |||
void summeDurch3() { | |||
assertTrue(zahlenfilterNeu.summeDurch3(5)); | |||
assertTrue(zahlenfilterNeu.summeDurch3(8)); | |||
assertFalse(zahlenfilterNeu.summeDurch3(7)); | |||
} | |||
} |