APL/APL2.1/TP05/Periode/MyPeriod.java

31 lines
621 B
Java
Raw Normal View History

2022-02-08 17:20:59 +01:00
public class MyPeriod {
private int length;
public String toString() {
return "Periode : " + length + " jour" + (length > 1 ? "s" : "");
}
public void addDay() {
this.length += 1;
}
public MyPeriod(MyDate date1, MyDate date2) {
if (date1.isEqual(date2)) {
this.length = 0;
return;
}
//Très dangereux et inefficace, ne faites pas ca svp.
while (!date1.isEqual(date2)) {
date1 = date1.tomorrow();
length++;
}
}
public MyPeriod(int length) {
this.length = length;
}
}