[View full width]
[View full width]
return (showMilitaryTime() theHour > 0 && theHour < 13)) ? theHour : (theHour == 0) ? 12 : theHour-12;
This conditional, written in shorthand form, says that if the user wants to show military time, or if the result of the hour portion of the time is greater than zero but less than 13, then simply return the variable
theHour . Remember that the
operator means a logical
or , as you first saw in Chapter 1. Otherwise , if
theHour is zero, then return with the result 12 (when the hour is 12 A.M.); otherwise return
theHour minus 12 (which converts hours 13 and higher to their civilian counterparts).