Frage

I am trying to move some code out of the main method and use it in another class. The reason for doing this is that I learnt it was advised convention to do so and I am relatively new to Java so looking to try it out. Currently when I move the code into the 'Game' class I cannot resolve the errors that eclipse is showing.

Any help would be appreciated.

Main method in playGame class-

 public class playGame {

        public static void main(String[] args) {
            // TODO Auto-generated method stub
            player playerOne = new player();
            GameHelper gameHelper = new GameHelper(); 
            wordManipulator thisWord = new wordManipulator();
            gameHelper.showDisplay();
            playerOne.setPlayerName();
            gameHelper.showIntro(playerOne.getPlayerName());
            thisWord.showHiddenWord();
            playerOne.setPlayerGuess();

        }

    }

The Game class

public class Game {

//other code for the game logic

}
War es hilfreich?

Lösung

Make sure to put your code in a method in the Game class, and then call that specific method.

Another hint : use capitals for class names.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top