public class Lendemain {
    private int annee;
    private int mois;
    private int jour;

    private static int[] JOURS_PAR_MOIS = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

    public Lendemain(int annee, int mois, int jour) {
        this.annee = annee;
        this.mois = mois;
        this.jour = jour;
    }

    public String toString() {
        return String.format("%04d-%02d-%02d", annee, mois, jour);
    }

    public Lendemain lendemain() {
        int newJour = this.jour + 1;
        int newMois = this.mois;
        int newAnnee = this.annee;

        if (newJour > JOURS_PAR_MOIS[this.mois - 1]) { 
            newJour = 1;
            newMois++;
            if (newMois > 12) { 
                newMois = 1;
                newAnnee++;
            }
        }

        return new Lendemain(newAnnee, newMois, newJour);
    }

   
    public int compare(Lendemain autre) {
        if (this.annee != autre.annee) {
            return Integer.compare(this.annee, autre.annee);
        }
        if (this.mois != autre.mois) {
            return Integer.compare(this.mois, autre.mois);
        }
        return Integer.compare(this.jour, autre.jour);
    }

    public static void main(String[] args) {
        Lendemain date = new Lendemain(2024, 2, 28);
        Lendemain lendemain = date.lendemain();
        
        System.out.println("Date actuelle : " + date); 
        System.out.println("Lendemain : " + lendemain); 

        //test
        Lendemain autreDate = new Lendemain(2024, 3, 1);
        System.out.println("Comparaison : " + date.compare(autreDate)); 
    }
}
