Я борюсь с этим очень простым кодом: я пытаюсь отпечатать отметки «_» с одним значком _ для каждой буквы в слове, введенном пользователем , Однако, когда я пытаюсь скомпилировать код, я получаю «error: метод makeLine в классе game_3 не может применяться к заданным типам, причина: фактические и формальные списки аргументов различаются по длине».Hangman Game: фактические и формальные списки аргументов различаются по длине
Это похоже на довольно четкую обратную связь, но я не думаю, что я действительно это понимаю. Сначала я думал, что это потому, что я не назначил значение stringNumber, но присвоение ему значения не помогло. Что не так?
/*Assignment:
Write a reverse Hangman game in which the user thinks of a word and the computer tries
to guess the letters in that word. Your program must output what the computer guessed
on each turn, and show the partially completed word. It also must use pseudorandom
functions to make guesses. That is, it should not simply try all the letters in order,
nor should it use the user’s input to its advantage.
*/
import java.util.*;
public class game_3 {
public static void main(String[] args) {
getIntroduction();
playGame();
}
public static void getIntroduction(){
System.out.println();
System.out.println();
System.out.println("*************************");
System.out.println("Welcome to Hangman");
System.out.println("In this game, you'll provide a word for the computer to guess.");
System.out.println();
System.out.println("The computer will guess letters randomly, and assess whether");
System.out.println("they can be used to complete your word.");
System.out.println();
System.out.println("Let's play!");
System.out.println();
System.out.println("*************************");
System.out.println();
}
public static void playGame(){
Scanner input = new Scanner(System.in);
System.out.print("Please enter a word: ");
String hangWord = input.next();
int stringNum = hangWord.length();
makeLine();
}
public static void makeLine(int stringNum){
for (int i = 0; i < stringNum; i++){
System.out.print("_ ");
}
}
}