Browse Source

made Methods public and added test file

master
Tim Lachmann 3 weeks ago
parent
commit
c2c18ad8a8

+ 2
- 0
Softwareengeneering.iml View File

@@ -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>

+ 5
- 5
src/Praktikum01/Zahlenfilter.java View File

@@ -28,21 +28,21 @@ public class Zahlenfilter {
}
}
}
public boolean filter(int i){
return !(checkDivideByFive(i) || checkEndsWithNine(i) || checkSumWithPrev(i)) ;
public static boolean filter(int i){
return !(checkDivideBy5(i) || checkEndsWith9(i) || checkSumDivideBy3(i)) ;
}
private Boolean checkDivideByFive(int i) {
public static Boolean checkDivideBy5(int i) {
return i % 5 == 0;
}
private Boolean checkEndsWithNine(int i) {
public static Boolean checkEndsWith9(int i) {
return i % 10 == 9;
}
private Boolean checkSumWithPrev(int i) {
public static Boolean checkSumDivideBy3(int i) {
if (i > 1) {
int vorgaenger = i - 1;
int summe = i + vorgaenger;

+ 33
- 0
test/Praktikum01/ZahlenfilterTest.java View File

@@ -0,0 +1,33 @@
package Praktikum01;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class ZahlenfilterTest {

@Test
void filter() {
}

@Test
void checkDivideBy5() {
assertTrue( Zahlenfilter.checkDivideBy5(155));
assertFalse( Zahlenfilter.checkDivideBy5(0));
assertFalse( Zahlenfilter.checkDivideBy5(-3));
}

@Test
void checkEndsWith9() {
assertFalse( Zahlenfilter.checkEndsWith9(155));
assertFalse( Zahlenfilter.checkEndsWith9(0));
assertFalse( Zahlenfilter.checkEndsWith9(-3));
assertTrue(Zahlenfilter.checkEndsWith9(99));
}

@Test
void checkSumDivideBy3() {
assertTrue( Zahlenfilter.checkSumDivideBy3(155));
}
}

Loading…
Cancel
Save