package topica.moduel;

import java.io.Serializable;
import java.util.Scanner;

public class Time implements Serializable {
	

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	int day,month , years;
	static Scanner sc= new Scanner(System.in);
	public Time() {
		// TODO Auto-generated constructor stub
	}

	public Time(int day, int month, int years) {
		super();
		this.day = day;
		this.month = month;
		this.years = years;
	}

	public int getDay() {
		return day;
	}

	public void setDay(int day) {
		this.day = day;
	}

	public int getMonth() {
		return month;
	}

	public void setMonth(int month) {
		this.month = month;
	}

	public int getYears() {
		return years;
	}

	public void setYears(int years) {
		this.years = years;
	}
	
	public void inputDay() throws ExceptionValue
	{
		System.out.print("Nhập ngày sinh : ");
    	this.day = Integer.parseInt(sc.nextLine());
    	if(this.day<0||this.day>31)
    		throw new ExceptionValue();
    }
	public void inputMonth() throws ExceptionValue
	{
		System.out.print("Nhập tháng sinh : ");
    	this.month = Integer.parseInt(sc.nextLine());
    	
    	if(this.month<1||this.month>12)
    		throw new ExceptionValue();
		
	}
	public void inputYears() throws ExceptionValue
	{
		System.out.print("Nhập năm sinh : ");
    	this.years = Integer.parseInt(sc.nextLine());
    	if(this.years<1900||this.years>2018)
    		throw new ExceptionValue();
	}
	
	public static int compare(Time t1 , Time t2)
	{
		int value = t1.years-t2.years;
		if(value!=0)
		{
			return value;
		}
		value = t1.month - t2.month;
		if(value!=0)
		{
			return value;
		}
		
		value = t1.day - t2.day;
		return value;
	}
	
	
	
	

}
