diff --git a/sources/src/main/java/pr2/vererbung/ueberladen_summe/Summator.java b/sources/src/main/java/pr2/vererbung/ueberladen_summe/Summator.java index f69bfe5..8f77dfb 100644 --- a/sources/src/main/java/pr2/vererbung/ueberladen_summe/Summator.java +++ b/sources/src/main/java/pr2/vererbung/ueberladen_summe/Summator.java @@ -2,4 +2,19 @@ package pr2.vererbung.ueberladen_summe; public class Summator { + public int sum(int a, int b) { + return a + b; + } + + public int sum(int a, int b, int c) { + return a + b + c; + } + + public int sum(int a, int b, int c, int d) { + return a + b + c + d; + } + + public int sum(int a, int b, int c, int d, int e) { + return a + b + c + d + e; + } } diff --git a/sources/src/main/java/pr2/vererbung/ueberladen_summe/test/SummatorTest.java b/sources/src/main/java/pr2/vererbung/ueberladen_summe/test/SummatorTest.java index 5d3496b..059053f 100644 --- a/sources/src/main/java/pr2/vererbung/ueberladen_summe/test/SummatorTest.java +++ b/sources/src/main/java/pr2/vererbung/ueberladen_summe/test/SummatorTest.java @@ -9,15 +9,15 @@ public class SummatorTest { @Test void testSum() { -// TODO: Einkommentieren -// Summator s = new Summator(); -// assertEquals(3, s.sum(1, 2)); -// assertEquals(1, s.sum(-1, 2)); -// assertEquals(6, s.sum(1, 2, 3)); -// assertEquals(0, s.sum(1, 2, -3)); -// assertEquals(10, s.sum(1, 2, 3, 4)); -// assertEquals(2, s.sum(1, 2, 3, -4)); -// assertEquals(15, s.sum(1, 2, 3, 4, 5)); -// assertEquals(5, s.sum(1, 2, 3, 4, -5)); + + Summator s = new Summator(); + assertEquals(3, s.sum(1, 2)); + assertEquals(1, s.sum(-1, 2)); + assertEquals(6, s.sum(1, 2, 3)); + assertEquals(0, s.sum(1, 2, -3)); + assertEquals(10, s.sum(1, 2, 3, 4)); + assertEquals(2, s.sum(1, 2, 3, -4)); + assertEquals(15, s.sum(1, 2, 3, 4, 5)); + assertEquals(5, s.sum(1, 2, 3, 4, -5)); } }