Free php web host - 294 Object-Based Programming Chapter 8 26 27 //
294 Object-Based Programming Chapter 8 26 27 // Time2 constructor: hour and minute supplied, second 28 // defaulted to 0 29 public Time2( int hour, int minute ) 30 { 31 SetTime( hour, minute, 0 ); 32 } 33 34 // Time2 constructor: hour, minute and second supplied 35 public Time2( int hour, int minute, int second ) 36 { 37 SetTime( hour, minute, second ); 38 } 39 40 // Time2 constructor: initialize using another Time2 object 41 public Time2( Time2 time ) 42 { 43 SetTime( time.hour, time.minute, time.second ); 44 } 45 46 // Set new time value in 24-hour format. Perform validity 47 // checks on the data. Set invalid values to zero. 48 public void SetTime( 49 int hourValue, int minuteValue, int secondValue ) 50 { 51 hour = ( hourValue >= 0 && hourValue < 24 ) ? 52 hourValue : 0; 53 minute = ( minuteValue >= 0 && minuteValue < 60 ) ? 54 minuteValue : 0; 55 second = ( secondValue >= 0 && secondValue < 60 ) ? 56 secondValue : 0; 57 } 58 59 // convert time to universal-time (24 hour) format string 60 public string ToUniversalString() 61 { 62 return String.Format( 63 "{0:D2}:{1:D2}:{2:D2}", hour, minute, second ); 64 } 65 66 // convert time to standard-time (12 hour) format string 67 public string ToStandardString() 68 { 69 return String.Format( "{0}:{1:D2}:{2:D2} {3}", 70 ( ( hour == 12 || hour == 0 ) ? 12 : hour % 12 ), 71 minute, second, ( hour < 12 ? "AM" : "PM" ) ); 72 } 73 74 } // end class Time2 Fig. 8.4 Fig. 8.Fig.Fi 8.4g. 8.44Overloaded constructors provide flexible object-initialization options. (Part Fig. 8. 2 of 2.) Because most of the code in class Time2is identical to that in class Time1, this discussion concentrates only on the overloaded constructors. Lines 15 18 define the no-argu
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.