I'm new to programming and I thought it would be fun to build a game, but I've run into an issue. I want to make it to where the user can collect an item once but once they collect it they can't collect it anymore. The way I'm seeing if they collect it is by changing the value of that variable from 0 to 1. This is what I've got for the collection, but it doesn't seem to be working. It's saying it can't find the variable yesCookie. I also want to point out that this is just the section that allows you to take it or not, the variable stuff is somewhere else.
if(moldyCookie == 0)
{
String yesCookie = "In a cavity within the wall you see a mold-covered cookie. Bleh. \nYou obtained the Rotten Cookie!\n";
}
else
{
String yesCookie = "There's nothing but an empty cavity in the wall. ";
}
System.out.println("You walk forward towards the painting, moving it aside."+yesCookie+"You return to the door.");
System.out.println();