From b1cda58c660f94a4b27cdec7ab55ce3f5289c905 Mon Sep 17 00:00:00 2001 From: Maxim Volkov Date: Thu, 17 Feb 2022 02:49:52 +0100 Subject: [PATCH] Added: Change Date of Birthday --- .../de/hs_fulda/ciip/projjpn/Birthdate.java | 12 ++++++++++ .../hs_fulda/ciip/projjpn/BirthdateTest.java | 22 ++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Birthdate.java b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Birthdate.java index 14062d7..f000456 100644 --- a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Birthdate.java +++ b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Birthdate.java @@ -10,6 +10,18 @@ public class Birthdate { month = m; year = y; } + + public int getDay() { + return day; + } + + public int getMonth() { + return month; + } + + public int getYear() { + return year; + } /** * @return Date Format TT.DD.YYYY diff --git a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/BirthdateTest.java b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/BirthdateTest.java index 312a870..23de888 100644 --- a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/BirthdateTest.java +++ b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/BirthdateTest.java @@ -4,9 +4,6 @@ import junit.framework.TestCase; public class BirthdateTest extends TestCase { - /** - * Test method for {@link de.hs_fulda.ciip.projjpn.Birthdate#toString()}. - */ public void testToString() { // Given @@ -18,4 +15,23 @@ public class BirthdateTest extends TestCase { // Then assertEquals(expectedDate, b.toString()); } + + public void test_changeBirthdate() { + // Given + Birthdate b = new Birthdate(1, 1, 2000); + + // Change Birthdate + b.changeBirthdate(2, 3, 2001); + + // When + int expectedDay = 2; + int expectedMonth = 3; + int expectedYear = 2001; + + // Then + assertEquals(2, b.getDay()); + assertEquals(3, b.getMonth()); + assertEquals(2001, b.getYear()); + } + }