package time;
/**
 * 
 * @author Yifei Zhu
 *
 *This class contain the time format
 *default--24
 *printing--12 
 */
public class Time extends Date
{
	private int hour;
	private int minute;
	private int second;
	
	
	public Time(int year, int month, int day, int hour, int minute, int second) {
		super(year, month, day);
		//time
		this.hour = hour;
		this.minute = minute;
		this.second=second;
	}


	public int getHour() {
		return hour;
	}


	public void setHour(int hour) {
		this.hour = hour;
	}


	public int getMinute() {
		return minute;
	}


	public void setMinute(int minute) {
		this.minute = minute;
	}


	public int getSecond() {
		return second;
	}


	public void setSecond(int second) {
		this.second = second;
	}

	public String get24Format()
	{
		return hour+":"+minute+":"+second;
	}
	public String get12Format()
	{
		if(this.hour>12)
		{
			return (this.hour-12)+":"+this.minute+":"+this.second+"PM";
		}
		else
		{
			return this.get24Format()+"AM";
		}
		
	}
	
	
	
	public String toString(int format) {
		if(format==12)
		{
			return this.toString()+" "+get12Format();
		}
		return this.toString()+" "+get24Format();
	}
	
	
	

	
	

}

@@ -1,16 +1,20 @@
 package 
+TEMP
 time;%0D%0A/
@@ -66,30 +66,192 @@
 ss c
-ontain the time format
+an be able to %0D%0A *%09-get date, hour, min, second%0D%0A *%09-get or print time and date in 12 format and 24 format%0D%0A *%09-compare to %22date and time%22%0D%0A *The default time format is in 24 hours%0D%0A *
 %0D%0A *
@@ -307,20 +307,35 @@
 ime 
-extends Date
+implements Comparable%3CTime%3E
 %0D%0A%7B%0D
@@ -399,16 +399,34 @@
 econd;%0D%0A
+%09private Date d;%0D%0A
 %09%0D%0A%09%0D%0A%09p
@@ -444,38 +444,8 @@
 int 
-year, int month, int day, int 
 hour
@@ -478,35 +478,12 @@
 %7B%0D%0A%09
-%09super(year, month, day);
 %0D%0A
+//
 %09%09//
@@ -1188,24 +1188,74 @@
 %0A%09%09%0D%0A%09%7D%0D%0A%09%0D%0A
+%09public Date getDate()%0D%0A%09%7B%0D%0A%09%09return this.d;%0D%0A%09%7D%0D%0A
 %09%0D%0A%09%0D%0A%09publi
@@ -1410,20 +1410,591 @@
 );%0D%0A%09%7D%0D%0A
+%0D%0A
 %09%0D%0A%09
+public int compareTo(Time dt)%0D%0A%09%7B%0D%0A%0D%0A%09%09if(dt==null)%0D%0A%09%09%09return -1 ; //TODO return -1?%0D%0A%09%0D%0A%09%09if(d.compareTo(dt.getDate())!=0)%0D%0A%09%09%7B%0D%0A%09%09%09return d.compareTo(dt.getDate());%0D%0A%09%09%7D%0D%0A%09%09//if date are the same%0D%0A%09%09%0D%0A%09%09//hour is different %0D%0A%09%09if(this.getHour()!=dt.getHour())%0D%0A%09%09%7B%0D%0A%09%09%09return this.getHour()-dt.getHour();%0D%0A%09%09%7D%0D%0A%09%09//if also have the %0D%0A%09%09else if(this.getMinute()!=dt.getHour())%0D%0A%09%09%7B%0D%0A%09%09%09return this.getMinute()-dt.getHour();%0D%0A%09%09%7D%0D%0A%09%09else if(this.getSecond()!=dt.getSecond())%0D%0A%09%09%7B%0D%0A%09%09%09return this.getSecond()-dt.getSecond();%0D%0A%09%09%7D%0D%0A%09%09else %0D%0A%09%09%7B%0D%0A%09%09%09return 0;%0D%0A%09%09%7D%0D%0A%09%0D%0A%09%7D
 %0D%0A%09%0D%0A%0D%0A%09

modify Time.java