From b575fc1b509ac862dfb9f47dc06484f8adbf889d Mon Sep 17 00:00:00 2001 From: Yan Wittmann <2121578@stud.hs-mannheim.de> Date: Tue, 8 Nov 2022 11:43:25 +0100 Subject: [PATCH] lt, eq, gt methods for date Signed-off-by: Skyball2000 --- aufgaben/src/Pflichtuebung_01/Date.elm | 15 ++++++-- aufgaben/tests/Pflichtuebung_01/DateTests.elm | 37 ------------------- 2 files changed, 12 insertions(+), 40 deletions(-) diff --git a/aufgaben/src/Pflichtuebung_01/Date.elm b/aufgaben/src/Pflichtuebung_01/Date.elm index 3559ab2..7f45347 100644 --- a/aufgaben/src/Pflichtuebung_01/Date.elm +++ b/aufgaben/src/Pflichtuebung_01/Date.elm @@ -23,11 +23,20 @@ day (a, _, _) = a -- 1 Punkt: lt : Date -> Date -> Bool -lt date1 date2 = False +lt date1 date2 = + let (d1, m1, y1) = date1 + (d2, m2, y2) = date2 + in y1 < y2 || (y1 == y2 && (m1 < m2 || (m1 == m2 && d1 < d2))) eq : Date -> Date -> Bool -eq date1 date2 = False +eq date1 date2 = + let (d1, m1, y1) = date1 + (d2, m2, y2) = date2 + in y1 == y2 && m1 == m2 && d1 == d2 gt : Date -> Date -> Bool -gt date1 date2 = False +gt date1 date2 = + let (d1, m1, y1) = date1 + (d2, m2, y2) = date2 + in y1 > y2 || (y1 == y2 && (m1 > m2 || (m1 == m2 && d1 > d2))) -- 1 Punkt: toString : Date -> String diff --git a/aufgaben/tests/Pflichtuebung_01/DateTests.elm b/aufgaben/tests/Pflichtuebung_01/DateTests.elm index 8edf960..d81d354 100644 --- a/aufgaben/tests/Pflichtuebung_01/DateTests.elm +++ b/aufgaben/tests/Pflichtuebung_01/DateTests.elm @@ -7,43 +7,6 @@ import Test exposing (..) import Pflichtuebung_01.Date exposing (..) - --type alias Day = - -- Int - -- - -- - --type alias Month = - -- Int - -- - -- - --type alias Year = - -- Int - -- - -- - --type alias Date = - -- ( Day, Month, Year ) - -- - ---- 1 Punkt: - --year : Date -> Year - ----year (a, b, c) = c - --month : Date -> Month - ----month (a,b,c) = b - --day : Date -> Day - ----day (a,b , c) = a - -- - --lt : Date -> Date -> Bool - --eq : Date -> Date -> Bool - --gt : Date -> Date -> Bool - -- - --toString : Date -> String - -- - --next : Date -> Date - -- - --prev : Date -> Date - -- - --leapyear : Year -> Bool - -- - --sub : Date -> Date -> Int - testYear : Test testYear = describe "year method test"