/** * A simple class to model a clock */ public class Clock { // hours, minutes and seconds // of the clock private int h, m, s; /** * Adds 1 second to the current time of the clock */ public Clock tick() { s++; if (s == 60) { m++; s = 0; if (m == 60) { h++; m = 0; } } return this; } /** * Returns a string representation of the time of the clock */ public String toString() { return h + "hrs " + m + "mins " + s + "secs"; } }