ProgrammingBasics
ProgrammingBasics copied to clipboard
Excercise05_01 (Show solution)
Excercise05_01 (Show solution)
ext fun endDateGreaterThanStartDate(c: Course) : boolean {
if c.endDate.year - c.startDate.year > 0 then true
else if c.endDate.year - c.startDate.year < 0 then false
else if c.endDate.month - c.startDate.month > 0 then true
else if c.endDate.month - c.startDate.month > 0 then true
else if c.endDate.month - c.startDate.month < 0 then false
else if c.endDate.day - c.startDate.day >= 0 then true else false
}
the line "else if c.endDate.month - c.startDate.month > 0 then true" is duplicated. Should month be replaced with day?
ext fun endDateGreaterThanStartDate(c: Course) : boolean {
if c.endDate.year - c.startDate.year > 0 then true
else if c.endDate.year - c.startDate.year < 0 then false
else if c.endDate.month - c.startDate.month > 0 then true
else if c.endDate.month - c.startDate.month < 0 then false
else if c.endDate.day - c.startDate.day >= 0 then true else false
}