

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


class Time{ int hours; int minutes; int seconds; public Time(){ hours=0; minutes=0; seconds=0; } public Time(int h, int m, int s){ hours = h; minutes = m; seconds = s; } void normalize(){ minutes+=seconds/60; seconds%=60; hours+=minutes/60; minutes%=60; hours%=24; } void advance(int h, int m, int s){ hours+=h; minutes+=m; seconds+=s;
normalize(); } void reset(int h, int m, int s){ hours = h; minutes = m; seconds = s; } void print(){ System.out.println(hours+":"+minutes+":"+seconds); } } public class welome { public static void main(String[] args) { Time t = new Time(12,38,20); t.advance(6,30,60); t.print(); } }