Let's say I have a class which has three properties as below.
public class Travel
{
public int MinAirportArrival { get; set; }
public int MinFlightTime { get; set; }
public int TotalTravelTime { get; set; }
}
TotalTravelTime must be at least the sum of MinAirportArrival and MinFlightTime but could also be more in the event there is a stopover or something of the sort.
It is clear to me that I can put logic in the setter for TotalTravelTime.
My question is regarding the changing of MinFlightTime and MinAirportArrival. Is it right to expect that TotalTravelTime be increased first and if not to throw an exception when one of the others will make the sum larger that TotalTravelTime?
What are my other options for controlling this in a reasonable fashion?
Should I just leave this to the object responsible for saving the state to check a valid property on the class? I may have other logic to put in there as well.
EDIT
I am not storing anywhere an amount for the extra time if there is any so this is not just a matter of adding up a few properties. Just to clarify this class is just a contrived example of the issue I am facing but I think it matches the problem pretty well.