ProgrammingBasics icon indicating copy to clipboard operation
ProgrammingBasics copied to clipboard

Excercise05_01 (Show solution)

Open Micha10 opened this issue 6 years ago • 0 comments

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
 }

Micha10 avatar Oct 16 '18 15:10 Micha10