marco cucinotta wrote:Well I tried it different ways but it either doesn't print anything or prints infinitely
And I hate to sound like a broken record here, but it's because you're simply
coding, rather than analysing WHAT you need to do
before you code.
Also: that statement above isn't true, because you've since proved that when you use a
for loop, it DOES work.
So what you need to do is work out
why.
I will give you a little tip though. Lines 17-20 of your
validate() method can be written a lot more simply, viz:
Winston