422 Object-Based Programming Chapter 8 1 // Fig.
422 Object-Based Programming Chapter 8 1 // Fig. 8.18: Time4.java 2 // Time4 class definition 3 package com.deitel.jhtp4.ch08; 4 5 // Java core packages 6 import java.text.DecimalFormat; 7 8 public class Time4 extends Object { 9 private int hour; // 0 - 23 10 private int minute; // 0 - 59 11 private int second; // 0 - 59 12 13 // Time4 constructor initializes each instance variable 14 // to zero. Ensures that Time object starts in a 15 // consistent state. 16 public Time4() 17 { 18 this.setTime( 0, 0, 0 ); 19 } 20 21 // Time4 constructor: hour supplied, minute and second 22 // defaulted to 0 23 public Time4( int hour ) 24 { 25 this.setTime( hour, 0, 0 ); 26 } 27 28 // Time4 constructor: hour and minute supplied, second 29 // defaulted to 0 30 public Time4( int hour, int minute ) 31 { 32 this.setTime( hour, minute, 0 ); 33 } 34 35 // Time4 constructor: hour, minute and second supplied 36 public Time4( int hour, int minute, int second ) 37 { 38 this.setTime( hour, minute, second ); 39 } 40 41 // Time4 constructor: another Time4 object supplied. 42 public Time4( Time4 time ) 43 { 44 this.setTime( time.getHour(), time.getMinute(), 45 time.getSecond() ); 46 } 47 48 // Set Methods 49 // set a new Time value using universal time 50 public Time4 setTime( int hour, int minute, int second ) 51 { 52 this.setHour( hour ); // set hour Fig. 8.18 Class Time4using thisto enable chained method calls (part 1 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 shared web hosting services