// B39HV2 Software Engineering II // Unit 2 Exercise 1 import java.io.*; public class Clock { public Clock(int h, int m, int s) { hour=h; minute=m; second=s; normalise(); } // Core of methods public void tick() { second = second + 1; // Add one second; normalise(); } public void show_time() { System.out.println(hour+":"+minute+":"+second); } public void normalise() { minute = minute + second / 60; // change minute if second > 60 hour = hour + minute/60; // change hour if minute > 60 minute = minute%60; // modulo 60 minutes hour = hour%24; // modulo 24 hours second = second%60; // modulo 60 seconds } private int hour,minute, second; // Private data of class };