Chapter 8 Object-Based Programming 423 53 this.setMinute( minute (Photo web hosting)

Chapter 8 Object-Based Programming 423 53 this.setMinute( minute ); // set minute 54 this.setSecond( second ); // set second 55 56 return this; // enables chaining 57 } 58 59 // validate and set hour 60 public Time4 setHour( int hour ) 61 { 62 this.hour = ( hour >= 0 && hour < 24 ? hour : 0 ); 63 64 return this; // enables chaining 65 } 66 67 // validate and set minute 68 public Time4 setMinute( int minute ) 69 { 70 this.minute = 71 ( minute >= 0 && minute < 60 ) ? minute : 0; 72 73 return this; // enables chaining 74 } 75 76 // validate and set second 77 public Time4 setSecond( int second ) 78 { 79 this.second = 80 ( second >= 0 && second < 60 ) ? second : 0; 81 82 return this; // enables chaining 83 } 84 85 // Get Methods 86 // get value of hour 87 public int getHour() { return this.hour; } 88 89 // get value of minute 90 public int getMinute() { return this.minute; } 91 92 // get value of second 93 public int getSecond() { return this.second; } 94 95 // convert to String in universal-time format 96 public String toUniversalString() 97 { 98 DecimalFormat twoDigits = new DecimalFormat( "00" ); 99 100 return twoDigits.format( this.getHour() ) + ":" + 101 twoDigits.format( this.getMinute() ) + ":" + 102 twoDigits.format( this.getSecond() ); 103 } 104 Fig. 8.18 Class Time4using thisto enable chained method calls (part 2 of 3). Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/3/01
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision personal web hosting services

Leave a Reply