Why does this not work; why do I suck at programming;
public static boolean validDate(int m, int d, int y){
if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12){
if (d < 1 || d > 31)
return false;
return true;
}else if (m == 4 || m == 6 || m == 9 || m == 11){
if (d < 1 || d > 30)
return false;
return true;
}else if (m == 2){
if ( d < 1 || d > 29)
return false;
if (d == 29 && leapYear(y))
return false;
return true;
}
return false;
}
it doesn't even work for absurdly wrong dates like 1234/1234/1234
Name:
Anonymous2011-04-08 0:01
this is leapYear()
private static boolean leapYear(int y){
if ( y % 4 != 0 )
return false;
if ( y % 100 != 0 )
return true;
if ( y % 400 != 0 )
return false;
return false;
}
Name:
Anonymous2011-04-08 0:07
What doesn't work?
Name:
Anonymous2011-04-08 0:09
>>3
public Date(int m, int d, int y){
day = d;
month = m;
year = y;
if (!validDate(m,d,y))
throw new IllegalArgumentException("Invalid Date");
}
You're just going to town trolling tonight, aren't you.
Regardless of your retardness, I'm not very proud of this program at all.
Name:
Anonymous2011-04-08 0:28
Christ, just run it through a debugger
Name:
nambla_dot_org_rules you2011-04-08 0:31
Okay, listen you fat autistic jew. I don't code on the level of "total retard aka SICP monkey". With that, here is how a real programmer would write the leapYear method..
>>1
It's supposed to work, at least for "absurdly wrong dates like 1234/1234/1234". Other than that, insert print statements to see what's going on. Good luck, ``faggot''.