26.07.2013 Views

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 8 Object-Based <strong>Program</strong>ming 407<br />

107 // add one <strong>to</strong> second and update hour/minute if necessary<br />

108 public void tick()<br />

109 {<br />

110 time.setSecond( ( time.getSecond() + 1 ) % 60 );<br />

111<br />

112 if ( time.getSecond() == 0 ) {<br />

113 time.setMinute( ( time.getMinute() + 1 ) % 60 );<br />

114<br />

115 if ( time.getMinute() == 0 )<br />

116 time.setHour( ( time.getHour() + 1 ) % 24 );<br />

117 }<br />

118 }<br />

119<br />

120 } // end class TimeTest5<br />

Fig. Fig. 8.9 8.9 Using class Time3’s set and get methods (part 3 of 4).<br />

© Copyright 1992–2002 by Deitel & Associates, Inc. All Rights Reserved. 7/3/01

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!