Building a 12 hour Clock
<p>I am currently attempting to build a data type Time() that interacts with input from a main class, to create a time on a 12 hour clock (e.g. the input (16, 47), would give you 4:47 PM) The methods can make adjustments to the inputted data that would normally be consider invalid to make it accurate again (e.g the input value for (28, -148) would remove 2 hours and 28 minutes from the hour 28 evaluating to (25, 32) and the 25 would evaluate to 1, giving a time of 1:32 AM). I'm getting the wrong values from what I've created so far, based on this driver program.</p>

<pre><code>package newProject;

/**
 * A program to test the Time class.
 *
 * 
 */
public class TestTime {

 public static void main(String[] args) {
    System.out.println("Basic Times\n"
                    +  "-----------");
    testTime(12, 30, 12, 30, "12:30 PM");
    testTime(16, 16, "4:00 PM");
    testTime(0, 0, 0, 0, "12:00 AM");
    testTime(0, 10, 0, 10, "12:10 AM");
    testTime(1, 5, 1, 5, "1:05 AM");
    testTime(11, 59, 11, 59, "11:59 AM");
    testTime(12, 12, "12:00 PM");
    testTime(12,1,12,1, "12:01 PM");
    testTime(13,55,13,55, "1:55 PM");
    testTime(23,55,23,55, "11:55 PM");
    System.out.println();

    System.out.println("Invalid Times\n"
                    +  "-------------");
    testTime(24, 0, "12:00 AM");
    testTime(49, 10, 1, 10, "1:10 AM");
    testTime(49, 125, 3, 5, "3:05 AM");
    testTime(-1, 23, "11:00 PM");
    testTime(0, -1, 23, 59, "11:59 PM");
    testTime(-27, 21, "9:00 PM");
    testTime(10, -125, 7, 55, "7:55 AM");
    testTime(-55, -308, 11, 52, "11:52 AM");
    System.out.println();

    System.out.println("addMinutes\n"
                    +  "----------");
    testAdd(0, 0, 20, 0, 20, "12:20 AM");
    testAdd(0, 0, 90, 1, 30, "1:30 AM");
    testAdd(0, 40, 30, 1, 10, "1:10 AM");
    testAdd(0, 40, 90, 2, 10, "2:10 AM");
    testAdd(23, 50, 11, 0, 1, "12:01 AM");
    testAdd(23, 50, 3 * 24 * 60 + 1, 23, 51, "11:51 PM");
    System.out.println();
}

/**
 * Test whether Time constructor, getters, and print 
 * are behaving properly when zero minutes.
 * 
 * @param hrs       what hour to say to the constructor
 * @param finalHrs  what hour the Time should end up with
 * @param rep       how that Time should print out
 */
private static void testTime(int hrs,
                             int finalHrs,
                             String rep) {
    System.out.print("new Time(" + hrs + ", 0) --&gt; " + finalHrs + ", 0: ");

    Time t = new Time(hrs, 0);
    if (t.getHour() == finalHrs &amp;&amp; t.getMinute() == 0)
        System.out.println("PASS");
    else
        System.out.println("FAIL");
    t.print();
    System.out.println(" should be " + rep);
}

/**
 * Test whether Time constructor, getters, and print are
 * behaving properly when minutes are not (necessarily) 0.
 * 
 * @param hrs           what hour to give the constructor
 * @param mins          what minute to give the constructor
 * @param finalHrs      what hour the Time should end up with
 * @param finalMins     what minute the Time should end up with
 * @param rep           how the Time should print out
 */
private static void testTime(int hrs, int mins,
                             int finalHrs, int finalMins,
                             String rep) {
    System.out.print("new Time(" + hrs + ", " + mins + ") --&gt; "
        + finalHrs + ", " + finalMins + ": ");

    Time t = new Time(hrs, mins);
    if (t.getHour() == finalHrs &amp;&amp; t.getMinute() == finalMins)
        System.out.println("PASS");
    else
        System.out.println("FAIL");
    t.print();
    System.out.println(" should be " + rep);
}

/**
 * Check whether addMinutes, getters, and print are working properly.
 * @param hrs           what hour to give the constructor
 * @param mins          what minute to give the constructor
 * @param addMins       the number of minutes to add to the Time
 * @param finalHrs      what hour the Time should end up with
 * @param finalMins     what minute the Time should end up with
 * @param rep           how the (later) Time should print out
 */
private static void testAdd(int hrs, int mins, int addMins,
                            int finalHrs, int finalMins,
                            String rep) {
    Time t = new Time(hrs, mins);
    Time t2 = t.addMinutes(addMins);

    System.out.print("Adding " + addMins + " minutes to ");
    t.print();
    System.out.print(" --&gt; ");
    if (t2.getHour() == finalHrs &amp;&amp; t2.getMinute() == finalMins)
        System.out.println("PASS");
    else
        System.out.println("FAIL");
    t2.print();
    System.out.println(" should be " + rep);
}
</code></pre>

<p>}</p>

<p>So far this is what I've put together for the methods required to modify these, but I don't really know where to go next.</p>

<pre><code>package newProject;


public class Time {

    private final int MAX_HOURS = 23;
    private final int MIN_HOURS = 0;
    private final int MAX_MINUTES = 59;
    private final int MIN_MINUTES = 0;
    private int hour;
    private int minute;

    private Time() {

    }

    public Time(int hrs, int mins) {
        this.hour = hrs;
        this.minute = mins;

    }

    private void fixMe() {
        if (minute &gt; MAX_MINUTES) {
            this.minute %= minute/60; 
            this.hour = minute/60 + hour;
        } 
        if (minute &lt; MIN_MINUTES) {
            this.minute = minute + 60;
        }
        if (hour &gt; MAX_HOURS) {
            this.hour %= hour/24; 
        } 
        if(hour &lt; MIN_HOURS) {
            this.hour = hour + 24;
        }

    }

    public int getHour() {
        return this.hour;
    }

    public int getMinute() {
        return this.minute;
    }

    public Time addMinutes(int mins) {
        Time t = new Time();
        t.fixMe();
        return t;

    }

    public void print() {

        if (hour == 0) {
            hour = 12;
        }
        if (hour &gt; 1 &amp;&amp; hour &lt;= 12) {
            System.out.print(hour);
        } else {
            System.out.print(hour - 12);
        }
        if (minute &lt; 10) {
            System.out.print(":0" + minute);
        } else {
            System.out.print(minute);
        }
        if (hour &lt;= 11) {
            System.out.print(" AM");
        } else 
            System.out.print(" PM");
    }

}
</code></pre>

<p>These are the outputs that I am getting, which are far from what I am looking for.</p>

<pre><code>    run:
Basic Times
-----------
new Time(12, 30) --&gt; 12, 30: PASS
1230 PM should be 12:30 PM
new Time(16, 0) --&gt; 16, 0: PASS
4:00 PM should be 4:00 PM
new Time(0, 0) --&gt; 0, 0: PASS
12:00 PM should be 12:00 AM
new Time(0, 10) --&gt; 0, 10: PASS
1210 PM should be 12:10 AM
new Time(1, 5) --&gt; 1, 5: PASS
-11:05 AM should be 1:05 AM
new Time(11, 59) --&gt; 11, 59: PASS
1159 AM should be 11:59 AM
new Time(12, 0) --&gt; 12, 0: PASS
12:00 PM should be 12:00 PM
new Time(12, 1) --&gt; 12, 1: PASS
12:01 PM should be 12:01 PM
new Time(13, 55) --&gt; 13, 55: PASS
155 PM should be 1:55 PM
new Time(23, 55) --&gt; 23, 55: PASS
1155 PM should be 11:55 PM

Invalid Times 
-------------
new Time(24, 0) --&gt; 0, 0: FAIL
12:00 PM should be 12:00 AM
new Time(49, 10) --&gt; 1, 10: FAIL
3710 PM should be 1:10 AM
new Time(49, 125) --&gt; 3, 5: FAIL
37125 PM should be 3:05 AM
new Time(-1, 0) --&gt; 23, 0: FAIL
-13:00 AM should be 11:00 PM
new Time(0, -1) --&gt; 23, 59: FAIL
12:0-1 PM should be 11:59 PM
new Time(-27, 0) --&gt; 21, 0: FAIL
-39:00 AM should be 9:00 PM
new Time(10, -125) --&gt; 7, 55: FAIL
10:0-125 AM should be 7:55 AM
new Time(-55, -308) --&gt; 11, 52: FAIL
-67:0-308 AM should be 11:52 AM

addMinutes
----------
Adding 20 minutes to 12:00 PM --&gt; FAIL
12:00 PM should be 12:20 AM
Adding 90 minutes to 12:00 PM --&gt; FAIL
12:00 PM should be 1:30 AM
Adding 30 minutes to 1240 PM --&gt; FAIL
12:00 PM should be 1:10 AM
Adding 90 minutes to 1240 PM --&gt; FAIL
12:00 PM should be 2:10 AM
Adding 11 minutes to 1150 PM --&gt; FAIL
12:00 PM should be 12:01 AM
Adding 4321 minutes to 1150 PM --&gt; FAIL
12:00 PM should be 11:51 PM
</code></pre>

<p>Ultimately if the program was working as its should, they would all evaluate to  PASS. Any help would be greatly appreciated</p>