Write a program to solve the Clock problem.

Define a class of objects called Clock. An object of type Clock stores time 
(hours and minutes) in military time format, in two instance variables of type 
int. Objects of type Clock have two instance methods: report which is simply 
returning the time, and tick which advances the clock by one minute. The 
constructor for class Clock takes one argument, a String that represents 
the time the clock is originally set to. Write a test program too, that 
illustrates how your objects are working. 

Here's my test program:

  class One {
    public static void main(String[] args) {
      Clock one = new Clock("2350"); 
      for (int i = 0; i < 20; i++) {
        one.tick(); 
    System.out.println(one.report()); 
      }
    }
  }

Here's my solution: 

  class Clock {
    int hours, minutes; 
    Clock(String time) {
      hours = Integer.parseInt(time.substring(0, 2)); 
      minutes = Integer.parseInt(time.substring(2)); 
    }
    void tick() {
      minutes += 1; 
      if (minutes == 60) { 
        minutes = 0; 
    hours += 1; 
      }
      if (hours == 24) {
        hours = 0; 
      }
    }
    String report() {
      String hours = "00" + this.hours; 
      String minutes = "00" + this.minutes;
      return 
        hours.substring(hours.length() - 2) + ":" + 
    minutes.substring(minutes.length() - 2); 
    }
  }

--