An abstract class Clock has been provided withfollowing instance variables1.hours2.mins3.secsThis class has an abstract method tick(). The responsibility of this methodis to represent the passage of 1 second but what time is reached afterticking depends upon whether the clock is 24 hrs or 12 hours.You need to provide two subclasses namely Clock12 and Clock24 which reprent the 12 and 24 hoursclock respectively. Override the tick() mehtod in each of these classes so that 1 tick increases the time by1 secont and updates all values (hrs min and seconds accordingly).On 24 hours clock 1 tick increases 1 second but consider the situation if the current time was 10:59:59then ticking once will make it 11:00:00. You will have to consider all situations. 1 second can mean justincrement in the seconds value. But if the seconds become 60 then you need to make it 0 again andincrement mins instead and so on. Also, after 23:59:59 the time becomes 00:00:00On the 12 hours clock we will have to take an additional member am (boolean). If am is true then the 12hours time is AM time otherwise its PM. Provide appropriate constructor for 12 hours clock to intializeall data members. Remember that in 12 hours clock the after 12:59:59 t AM The time becomes 01:00:00PM. Similarly if originally its PM then it becomes AM.Override the toString method for the 12 hours clock.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here