31 lines
621 B
Java
31 lines
621 B
Java
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;
|
|
}
|
|
|
|
|
|
} |