Jenia Levin wrote:this is the method from my class Date
You have a general problem in the way you are going about your development. Your work flow should be: write a small piece of code, get it to compile, then test it thoroughly before developing any more. And for testing you could simply make a main() method that calls your new code with a number of different inputs and compares the outputs to a hard coded output. If the output does not match the expected output then your test failed. Also test for invalid input; for example, what should it do if given a negative year?
The reason I bring this up is that I'm detecting a lot of suspect logic in your code and without testing I don't see how you could have any confidence in your code. Be aware that many developers have worked on the date problem and it is not an easy one to get correct.
Case in point is your before() method, it's logic is oversimplified and incorrect. Here is a working version based on an implementation of the compareTo() method.
Hi Jenia, I agree with what Carey says. I'll add that it often is much quicker to write your code slowly and thoroughly, because you will not get stuck so often. As someone who is still fairly new to coding, I find that being able to read your own code is hugely important. If you can't read it, you can't tell what is wrong. Even if it takes longer, make sure that you format your code well and consistently. Take a good look at how Carey has written it. The brackets match up; the indentation is even. It is 100 times easier to spot a syntax error, because it looks different to how it should.
It seems to me that you have jumped into the deep end working with dates. What are you writing this code for, is it an assignment?