// Arup Guha
// 4/5/2010
// Part of Solution for 2008 AP Free Response Question #1: Flights

// Note: We assume that all times are within the same day.

public class Time {
	
	private int hour;
	private int minute;
	
	// Default Time object - midnight
	public Time() {
		hour = 0;
		minute = 0;
	}
	
	// Sets time (in military time) to hr:min.
	public Time(int hr, int min) {
		hour = hr;
		minute = min;
	}
	
	// Returns the number of minutes from this until other. If other comes
	// first, a negative number is returned.
	public int minutesUntil(Time other) {
		return 60*(other.hour-this.hour) + other.minute - this.minute;
	}
	
	// Unnecessary for the solution.
	public String toString() {
		
		String min = "" + minute;
		int hr = hour;
		
		// Add a zero, if necessary.
		if (minute < 10)
			min = "0" + min;
		
		// Adjust the hour for regular time.
		if (hr == 0)
			hr += 12;
		if (hr > 12)
			hr -= 12;
			
		// Return the answer with the correct "suffix"
		if (hr < 12)
			return hr+":"+min+" AM";
		else
			return hr+":"+min+" PM";	
		
	}
}