Browse Source

made Methods public and added test file

master
Tim Lachmann 3 weeks ago
parent
commit
c2c18ad8a8

+ 2
- 0
Softwareengeneering.iml View File

<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="junit.jupiter" level="project" />
</component> </component>
</module> </module>

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

} }
} }
} }
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; return i % 5 == 0;
} }
private Boolean checkEndsWithNine(int i) {
public static Boolean checkEndsWith9(int i) {
return i % 10 == 9; return i % 10 == 9;
} }
private Boolean checkSumWithPrev(int i) {
public static Boolean checkSumDivideBy3(int i) {
if (i > 1) { if (i > 1) {
int vorgaenger = i - 1; int vorgaenger = i - 1;
int summe = i + vorgaenger; int summe = i + vorgaenger;

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

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