예제 #1
0
        private bool bedTimePreceedsEndTime(TwentyFourHourTime bedTime)
        {
            switch (_endTimePeriod)
            {
            case TIME_OF_DAY.PM:
                if (bedTime.CompareTo(StartTime) >= 0 && bedTime.CompareTo(EndTime) <= 0)
                {
                    return(true);
                }
                throw new ArgumentException("Bed time must come before end time");
                return(false);

                break;

            default:
                if (bedTime.CompareTo(EndTime) <= 0 || bedTime.CompareTo(EARLIEST_START_TIME) >= 0)
                {
                    return(true);
                }
                throw new ArgumentException("Bed time must come before end time");
                return(false);

                break;
            }
        }
예제 #2
0
        private bool startTimePreceedsEndTime(TwentyFourHourTime endTime)
        {
            switch (_startTimePeriod)
            {
            case TIME_OF_DAY.AM:
                if (endTime.CompareTo(_startTime) >= 0 && endTime.CompareTo(LATEST_END_TIME) <= 0)
                {
                    return(true);
                }
                throw new ArgumentException("End time must come after start time");
                return(false);

                break;

            default:
                if (endTime.CompareTo(_startTime) >= 0 || endTime.CompareTo(LATEST_END_TIME) <= 0)
                {
                    return(true);
                }
                throw new ArgumentException("End time must come after start time");
                return(false);

                break;
            }
        }
예제 #3
0
 private bool bedTimeIsValid(TwentyFourHourTime bedTime)
 {
     if (startTimePreceedsBedTime(bedTime) && bedTimePreceedsEndTime(bedTime))
     {
         return(true);
     }
     return(false);
 }
예제 #4
0
 private bool startTimePreceedsBedTime(TwentyFourHourTime bedTime)
 {
     if (bedTime.CompareTo(StartTime) >= 0)
     {
         return(true);
     }
     throw new ArgumentException("Bed time must come after start time");
     return(false);
 }
예제 #5
0
 private bool endTimeIsValid(TwentyFourHourTime endTime)
 {
     if ((endTime.CompareTo(EARLIEST_START_TIME) >= 0 || endTime.CompareTo(LATEST_END_TIME) <= 0) && startTimePreceedsEndTime(endTime))
     {
         return(true);
     }
     throw new ArgumentOutOfRangeException("Babysitters cannot work after 4:00AM");
     return(false);
 }
예제 #6
0
 private bool startTimeIsValid(TwentyFourHourTime startTime)
 {
     if (startTime.CompareTo(EARLIEST_START_TIME) >= 0)
     {
         return(true);
     }
     throw new ArgumentOutOfRangeException("Babysitter cannot start work before 5:00PM or after Midnight");
     return(false);
 }
예제 #7
0
        /// <summary>
        /// This constructor for a TimeCard must include a start and an end time.
        /// </summary>
        /// <param name="startTime">Time shift began, valid range: 17:00 - 04:00</param>
        /// <param name="endTime">Time shift ended, valid range: 17:00 - 04:00, must come after <see cref="StartTime"/></param>
        public BabysitterTimeCard(TwentyFourHourTime startTime, TwentyFourHourTime endTime)
        {
            if (startTimeIsValid(startTime))
            {
                _startTime = startTime;
            }

            _startTimePeriod = enumerateStartTimePeriod();

            if (endTimeIsValid(endTime))
            {
                _endTime = endTime;
            }
        }