There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Walid Sakr wrote:please help
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Junilu Lacar wrote:Just a side note: this would be a perfect program to do in the Greenfoot environment.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Walid Sakr wrote:please help
Follow Fred's advice and you'll soon work out what's wrong.
My advice is more general: Your solution is very procedural.
How do I know that?
1. You only have one class.
2. All your methods are static.
3. Your main() method is very large.
Now there's nothing particularly terrible about that, but Java is an object-oriented language, so it generally works best with objects. What you've written could have been done in C or Basic.
For example, if you had a Board class, you could hide all that fiddly logic inside it, viz:and your main() might then look something like:Furthermore, you could then put your Board object inside a ConnectFour class (possibly a modification of the one you've already got) whose business it is to run the game. Then your main() might look something like:and there you have it: A complete game driver in 6 lines.
Please note that the above is just for illustration; there are MANY ways to do this, but the best ones are likely to involve making objects do the work for you.
HIH
Winston
Walid Sakr wrote:...but this is how my mind figures it out first i concentrate on the engine "how this problem will be solved" then i re arrange it into classes and objects.
getting back to my problem i have tested this part of the program using all possible ways "i know of " of course including what Fred mentioned in his post above but the addDisk method is not returning any result actually it has no impact on the board array i was seeking technical advise (a wrong assumption, passing the array to the method in an unusual way .....) anything that your expert eyes can see that i can't see
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here