/* CS193J Time.java
 */ 


/**
 * This simple class is designed to just manage a time (hour and minute)
 * somewhat based on the example we were using in lecture, but uses the
 * simple to understand, but hard to manipulate internal representation
 * of the hour, minute, and am/pm status.
 * It's not very fancy, but gives you something to start with. Think of it
 * as a "straw man" proposal. I would pretty much recommend throwing 
 * it out and starting over from scratch, to design the class the way you 
 * think it will work best. 
 *
 * @version      1.1 10/1/99
 * @author       Your name here!
 */

public class Time {

	private int hour, minute;		// instance variables
	private boolean isAM;
									// class-wide constants
	private static final int MaxHour = 12, MaxMinute = 60; 

	/**
	 * Constructor takes the arguments, the hour, minute, and
	 * whether it is a Am or Pm time (true is Am, false is Pm)
	 */
	public Time(int hour, int minute, boolean isMorning)
	{
		setHour(hour);
		setMinute(minute);
		setIsMorning(isMorning);
	}

	/**
	 * Simple setter to change value of hour field, but
	 * handles two important constraints: makes sure time is
	 * not greater than 12, and changes 0 to 12. It might be a
	 * good idea for all changes to hour instance variable to go 
	 * through this method to ensure object consistency.  Does
	 * this method need to exist? Should it be public? These
	 * questions are yours to decide.
	 */
	public void setHour(int hr)
	{
		hour = hr % MaxHour;
		if (hour == 0) hour = MaxHour; // report 12 o' instead of 0
	}
	
	
	/**
	 * Simple setter to change value of minute field, but handles on
	 * additional constraint that the minute shouldn't exceed 60.  
	 * Like hour, it might be wise for all changes to minute to go 
	 * through this method to ensure object consistency.  Does
	 * this method need to exist? Should it be public? These
	 * questions are yours to decide.
	 */
	public void setMinute(int min)
	{
		minute = min % MaxMinute;
	}
	
	/**
	 * Simple setter to change value of isAM flag, nothing special 
	 * here, but if we ever were to change behavior in some way in 
	 * future, we may find more vaule in this method as a funnel for 
	 * changing this field.
	 */
	public void setIsMorning(boolean flag)
	{
		isAM = flag;
	}
}
