Java clock composed of two display objects
<p>I've got this homework assignment that has me stumped.  I've got a <strong>24 hour clock</strong> thaot is composed of two <strong>numberDisplay</strong> objects.
<strong>numberDisplay</strong> objects have a limiter that roles them over, so when minutes hits 60 it rolls back to zero and increments hours.  When hours hits 24 it rolls back to zero.</p>

<p><strong>I am tasked with changing it from a 24 hour clock to a 12 hour clock, but I cannot change anything about the objects.  Only how they interact</strong></p>

<p>I've managed this so far:</p>

<pre><code>private void updateDisplay()
{
    int functionHours = Integer.parseInt(hours.getDisplayValue());
    String amPM = "AM";
    if ( functionHours == 0 ) {
        hours.setValue(12);
        amPM = "AM";
    }
    else if ( functionHours &gt; 0 &amp;&amp; functionHours &lt; 12 )
    {
        hours.setValue(functionHours);
        amPM = "AM";
    }
    else if ( functionHours == 12 ) {
        hours.setValue(functionHours);
        amPM = "PM";
    }
    else if ( functionHours &gt; 12 &amp;&amp; functionHours &lt;= 23 ) {
        functionHours -= 12;
        hours.setValue(functionHours);
        amPM ="PM";
    }
    displayString = hours.getDisplayValue() + ":" + minutes.getDisplayValue() + " " + amPM;
}
</code></pre>

<p>However when hours.value changes from 23 back to zero, the clock refuses to change back to AM.  I am stumped how to accomplish this.</p>

<p>NumberDisplay object:</p>

<pre><code>/**
 * The NumberDisplay class represents a digital number display that can hold
 * values from zero to a given limit. The limit can be specified when creating
 * the display. The values range from zero (inclusive) to limit-1. If used,
 * for example, for the seconds on a digital clock, the limit would be 60, 
 * resulting in display values from 0 to 59. When incremented, the display 
 * automatically rolls over to zero when reaching the limit.
 * 
 * @author Michael Kölling and David J. Barnes
 * @version 2011.07.31
 */
public class NumberDisplay
{
    private int limit;
    private int value;

    /**
     * Constructor for objects of class NumberDisplay.
     * Set the limit at which the display rolls over.
     */
    public NumberDisplay(int rollOverLimit)
    {
        limit = rollOverLimit;
        value = 0;
    }

    /**
     * Return the current value.
     */
    public int getValue()
    {
        return value;
    }

    /**
     * Return the display value (that is, the current value as a two-digit
     * String. If the value is less than ten, it will be padded with a leading
     * zero).
     */
    public String getDisplayValue()
    {
        if(value &lt; 10) {
            return "0" + value;
        }
        else {
            return "" + value;
        }
    }

    /**
     * Set the value of the display to the new specified value. If the new
     * value is less than zero or over the limit, do nothing.
     */
    public void setValue(int replacementValue)
    {
        if((replacementValue &gt;= 0) &amp;&amp; (replacementValue &lt; limit)) {
            value = replacementValue;
        }
    }

    /**
     * Increment the display value by one, rolling over to zero if the
     * limit is reached.
     */
    public void increment()
    {
        value = (value + 1) % limit;
    }
}
</code></pre>
