Challenge: Overload a Function

Here is a coding challenge based on the concepts of function overloading.

We'll cover the following

Problem statement

Consider you have a function info():

void info(TimeOfDay time) {
    writef("%02s:%02s", time.hour, time.minute); 
}

Your task is to overload the info() function for the following structs as well:

struct Meal {
    TimeOfDay time;
    string    address;
}

struct DailyPlan {
    Meeting amMeeting;
    Meal    lunch;
    Meeting pmMeeting;
}

Since Meal only has the start time, add an hour and a half to determine its end time. You can also use the addDuration() function:

TimeOfDay addDuration(TimeOfDay start, TimeOfDay duration) {
    TimeOfDay result;

    result.minute = start.minute + duration.minute; 
    result.hour = start.hour + duration.hour; 
    result.hour += result.minute / 60;

    result.minute %= 60; 
    result.hour %= 24;
    
    return result;
}

Get hands-on with 1200+ tech skills courses.