Post your code here along with all compiler messages and/or exceptions as well as a descritpion of what it is suppossed to do and what it actually does and exactly how they differ, and we will help you to correct your own code, but you are going to have to do it.
>>i found it from a book. >>is it cheating to learn from any body who knows well?
I don't believe that code comes from a book. If that person ``who knows well' writes such code, full with magic numbers, and no comments at all - just to give a few examples of bad practice - and then publishes this rubbish, then I wouldn't dare to say that this person ``knows well'.
The reason why you're not getting much help is because you're copying and pasting code and asking us to explain it to you. You're not showing any effort at all.
We can help explain to you concepts, for example what's a method, and help you debug your code, but you have to actually try to write the code.
Furthermore, oftentimes writing code helps you answer a lot of your questions (e.g. where does the move() method come from, how does it work).