The method println(char) in the type PApplet is not applicable for the arguments (int, char)

I am trying to make a basic hangman game. I get the following error when running this piece of code - The method println(char) in the type PApplet is not applicable for the arguments (int, char). I am not very experienced with coding and would appreciate any help in resolving this problem.

Thank you!

//HANGMAN

PFont myFont; int numRight=0; int winner=0; // length of answer

//Declare array of words

String[] game = { "TENNIS", "HOCKEY", "SOCCER", "RUGBY" }; int answerKey = 0; //index for game array String answer=""; //holds answer char guessed[];//correct guesses char wrong[];// wrong guesses

//varibale to store display string String display = "Please type the letter you wish to guess: "; String display2 = "Followed by enter"; String display3 = "";

// variable to store current type String typing = "";

//variable to store saved text when return pressed String guess = "";

void setup() { size(600,600); myFont= createFont("Verdana", 16 , true); answerKey = int(random(0, game.length)); answer= game[answerKey];

// answer into char array char[] gameChar = new char[answer.length()]; guessed = new char [answer.length()]; for (int i = 0; i < answer.length(); i++) { gameChar[i] = answer.charAt(i); guessed[i] = '_'; println(i, gameChar[i]);

} }

void draw() { background(255); int indent=25; display3 ="";

//font and fill for text

textFont(myFont); fill(0);

for (int i = 0; i< guessed.length; i++) { display3 = display3 + " "+ guessed [i]; } //testing text(display3, indent, 200);

text(display, indent, 400); text(display2, indent, 430); text(typing,indent, 490); guess = typing;

if (guess.length() > 1) { display = ("Please type only one letter"); typing= " "; } }

void keyPressed() { // return key pressed, save the string and clear it if (key == '\n' ) { play(typing); //clear string typing= ""; } else { typing = typing + key; } }

void play (String guess) { guess = guess.toUpperCase(); char myGuess = guess.charAt(0); for ( int c = 0; c< answer.length(); c++) { println(myGuess, answer.charAt(c)); if (myGuess == answer.charAt(c)) { guessed[c] = myGuess; } } }

Answers

Sign In or Register to comment.