Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Something I must have missed in Java...?
So this will probably be a simple answer for most of you, but I guess I somehow never learned this in my first java class, and now it's important.
Lets say I am writing a program for a game. This game has a few different classes in it, and they need to be available to eachother.
We'll say I have a main method in the first class, which prompts the user for inputs, such as the size of the game board.
Now I have another method that creates the game board.
I have a third method that displays the game board.
a fourth method that places pieces etc.
So, what I need to do, is run the main method, take the inputs and run them in the "createboard", then use what I have to run "display board" and finally run the "addpiece" methods, followed by "displayboard" again. After this, addpiece and display board and whatever else is involved will need to be used again and again until the game is over.
Long question shorter....how do I call the other methods, get them to run, and then return to the main method so that I can call the next one?
It seems simple, I must be missing something.
1 Answer
- Anonymous10 years agoFavorite Answer
give the method a name and then type is code. relate the code to that name and then when you need to call them just type the code to call the name you gave to the method and it should run.
It has been 3 years since I did Java so I cant really remember the details but that's how you do it in general