The following timer class measures the total time that has elapsed after timing a number of events. Your job is to implement the add method so that it correctly updates the hours and minutes fields. For example, consider this sequence of statements:

Timer t = new Timer();
t.add(40); // 40 minutes
t.add(50); // another 50 minutes
System.out.println(t.getTotal()); // prints 1:30, one hour and 30 minutes

Complete the following file:

Timer.java

/** A timer keeps tracks of the total elapsed time. */ public class Timer { private int hours; private int minutes; /** Construct a timer with 0:0O elapsed time */ public Timer() { hours = 0; minutes = 0; } /** Adds a given number of minutes to the elapsed time. @param minutesToAdd the number of minutes (>=0; may be larger than 60) */ public void add(int minutesToAdd) { // your work here } /** Gets the total elapsed time. @return a string describing the total time in the format h:mm, with mm < 60 */ public String getTotal() { return String.format("%d:%02d", hours, minutes); } }

Use the following file:

TimerTester.java

public class TimerTester
{
   public static void main(String[] args)
   {
      Timer t = new Timer();
      t.add(40); // 40 minutes
      t.add(50); // another 50 minutes
      System.out.println("Total: " + t.getTotal()); 
      System.out.println("Expected: 1:30");
   }
}