package a202; public class Clock { int hour; int minute; //takes something like "2350" public Clock(String input){ String hourString = input.substring(0,2); String minuteString = input.substring(2, 4); hour = (int)Integer.valueOf(hourString); minute = (int)Integer.valueOf(minuteString); } public void tick(){ minute = minute + 1; if(minute > 59){ minute = 00; hour = hour + 1; } if(hour > 23){ hour = 00; } } public String report(){ String time = ""; String reportHour= ""; String reportMinute = ""; if(hour < 10){ reportHour = "0" + hour; } else{ reportHour = "" + hour; } if(minute < 10){ reportMinute = "0" + minute; } else{ reportMinute = "" + minute; } time = reportHour + ":" + reportMinute; return time; } public static void main(String[] args){ Clock one = new Clock("2350"); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); one.tick(); System.out.println("the time is: " + one.report()); } }