i have a class month, day and year my toSring() is public String toString() { String report; report = "+ month / + day / + year"; //report = report + "+ day"; //report = report + "+ year"; return report; } i take out the 2 lines of // because the assignment asks me to do toString(): String [in the format of mm/dd/yyyy is my toString method correct? thanks.
It doesn't appear to do what you want. You said you have a class month day year, but since you have spaces I assume that means you have either 3 variables in a class or 3 classes with those names. I'll assume the first case. If your class were something such as -
This should get you started. HTH. Regards, Aaron R> [ October 27, 2003: Message edited by: Aaron Roberts ]
Here is my code: (it compiles fine and runs but i need to know if i am doing the assignment correctly. thanks) public class Date { private int day; private int month; private int year;
I can't answer if you are doing the assignment correctly, as I don't know what the assignment is. If your assignment tells you exactly what your class should do and your class does that, everything must be right. Did you check to see if the toString method outputs the date in the format you wanted? When I was in school, I was scored based on how good my comments were, whether the routines actually worked, etc. Regards, Aaron R>
"Don't believe every tiny ad you see on the internet. But this one is rock solid." - George Washington
Gift giving made easy with the permaculture playing cards