/**
 * H parakatw klasi prospa8ei na kanei oti kai i klasi Date, alla me diaforetiki ulopoiisi.
 *
 * (
 *
 * @author Vouzoukidou Nelly, email: vuzukid (at) csd (dot) uoc (dot) gr
 */
public class MyNewDate {
    private int date; // days after 1/1/2000

    public MyNewDate() {
        date = 0; // 1/1/2000
    }

    public MyNewDate(int day, int month) {
        this.date = month * 30 + day;
    }

    public MyNewDate(int day, int month, int year) {
        this.date = year * 360 + (month - 1) * 30 + day;
    }

    //getter
    public int getDay() {
        return date - getYear() * 360 - (getMonth() - 1) * 30;
    }

    public int getMonth() {
        return (date - getYear() * 360) / 30 + 1;
    }

    public int getYear() {
        return date / 360;
    }

    public boolean isLeap() {
        return getYear() % 4 == 0 && (getYear() % 100 != 0 || getYear() % 400 == 0);
    }

    public void setDay(int day) {
        if (day < 1 || day > 30) {
            throw new IllegalArgumentException("Day must be in [1, 30]. Found " + day + " instead");
        }
        date += day - getDay();
    }

    public void setMonth(int month) {
        if (month < 1 || month > 12) {
            throw new IllegalArgumentException("Month must be in [1, 12]. Found " + month + " instead");
        }
        date += month * 30 - getMonth() * 30;
    }

    public void setYear(int year) {
        if (year < 1) {
            throw new IllegalArgumentException("Year must be a positive number. Found " + year + " instead");
        }
        date += year * 360 - getYear() * 360;
    }

    public void increaseDays(int days) {
        date += days;
    }
}
