I am working on an APCS assignment to make a date class, and in it we needed an addDays method that add days to a date. So for example in the client code it would say date1.addDays(60000)
My code works for some addDays (ex. 1000) but doesn't work for others (ex. 60000)
public void addDays(int days){
while(days>0){
day++;
days--;
if(day>daysInMonth(month)){
month++;
day = 1;
}
if(month>12){
year++;
month = 1;
day = 1;
}
}
}
Aucun commentaire:
Enregistrer un commentaire