Fin du TP Heritage

This commit is contained in:
Simoes Lukas
2025-02-06 14:32:11 +01:00
parent 209f320a5a
commit dd0903e9fc
21 changed files with 304 additions and 20 deletions

35
DEV2.1/TP04/Periode.java Normal file
View File

@@ -0,0 +1,35 @@
public class Periode {
private Date debut;
private Date fin;
public Periode(Date debut, Date fin) {
this.debut = debut;
this.fin = fin;
}
public String toString() {
return this.debut.toString() + " - " + this.fin.toString();
}
public void rallongeUneJournee() {
this.fin = this.fin.lendemain();
}
public int nombreDeJours() {
int compteur = 0;
Date temp = this.debut;
while (!temp.dateEgaleA(this.fin)) {
compteur++;
temp = temp.lendemain();
}
return compteur;
}
public static void main(String[] args) {
Periode p = new Periode(new Date(12,2,2025), new Date(17,2,2025));
System.out.println(p);
p.rallongeUneJournee();
System.out.println(p);
System.out.println("Nombre de jours entre les 2 dates : " + p.nombreDeJours());
}
}