Java Java Objects Delivering the MVP Arrays and Command Line Arguments

Joshua Thao
Joshua Thao
2,686 Points

How do we set the "Answer" in an IDE? I have Intellij and if I run my code it just says answer is required.

import java.sql.SQLOutput;

import static java.lang.System.*;

public class Hangman {

public static void main(String[] args) {

    if(args.length == 0){ // checking to see if we put an answer for the game
        out.println("Usage: java Hangman <answer>");
        err.println("answer is required!");
        System.exit(1);
    }

    Game game = new Game(args[0]);
    Prompter prompter = new Prompter(game);

    while (game.getRemainingTries() > 0 && !game.isWon()) {
        prompter.displayProgress();
        prompter.promptForGuess();
    }
    prompter.displayOutcome();

}

}

2 Answers

Allan Clark
MOD
Allan Clark
Treehouse Moderator 10,772 Points

All IDEs have a place where you can input command line arguments. I am not familiar with Intellij but this StackOverflow question should help.

https://stackoverflow.com/questions/2066307/how-do-you-input-commandline-argument-in-intellij-idea