package metab; import java.io.*; /** * The DrinkTime class has use only in containing a time of day. * It does not specify a date for simplicity. It relies on hours, minutes, and * a 12-hour (non-military) clock to hold the time. This class was designed * instead of using the Date-types because neither milliseconds nor * specific dates were required. * @author Levi Blackstone, Matthew Woller * @version 1.03 */ public class DrinkTime implements Serializable{ /** * Standard value representing AM hours. */ public static final int _AM = 1; /** * Standard value representing PM hours. */ public static final int _PM = 0; /** * Number of hours. */ private int hours; /** * Number of minutes. */ private int minutes; /** * Specifies whether time is AM or PM. */ private int AMorPM; /** * Constructor for DrinkTime class. * @param hours Number of hours. * @param minutes Number of minutes. * @param AMorPM Specifies whether time is AM or PM. */ DrinkTime(int hours, int minutes, int AMorPM) { this.hours = hours; this.minutes = minutes; this.AMorPM = AMorPM; } /** * Retrieves number of hours. * @return int representing number of hours. */ public int getHours() { return hours; } /** * Retrieves number of minutes. * @return int representing number of minutes. */ public int getMinutes() { return minutes; } /** * Retrieves 12-hour format information. * @return int representing whether time is AM or PM. */ public int getAMorPM() { return AMorPM; } /** * Retrieves a copy of time encompassing drinking period. * @return DrinkTime representing new instance of current time. */ public DrinkTime getCopy() { return new DrinkTime(hours, minutes, AMorPM); } /** * Sets number of hours. * @param hours Number of hours. */ public void setHours(int hours) { this.hours = hours; } /** * Sets number of minutes. * @param minutes Number of minutes. */ public void setMinutes(int minutes) { this.minutes = minutes; } /** * Sets whether time is AM or PM. * @param AMorPM Specifies whether time is AM or PM. */ public void setAMorPM(int AMorPM) { this.AMorPM = AMorPM; } }