/** * A Time object represents a particular time of day, such as 11:30 PM. * @pre 1 <= hour <= 12, 0 <= minute <= 59 * @author Marty Stepp * @version CSE 331 Spring 2011, 5/25/2011 */ public class Time { private int hour; private int minute; private boolean pm; // false = AM, true = PM /** * Constructs a new time representing the given time of day. */ public Time(int hour, int minute, boolean pm) { this.hour = hour; this.minute = minute; this.pm = pm; } /** * Returns an integer hash code for this object based on its state * (hour, minute, and am/pm). * Note the use of the @Override annotation below to indicate that we * are overriding a method from the Object superclass. */ @Override public int hashCode() { return 67 * hour + minute + (pm ? 1000000 : 0); } }