Iam very new to programming and am trying to make a simple game(for my final) where a user has to pick a path and depending on the path he takes he will either live or die. i get this error
symbol : variable badPath
location: class FinalS1
if (Path == badPath)
import java.util.Scanner; import java.util.Random; public class FinalS1 { public static void main (String[] args) { Scanner scan = new Scanner(System.in); int Path; System.out.println(" ________ __ "); System.out.println("| | | |.-----.| |.----.-----.--------.-----."); System.out.println("| | | || -__|| || __| _ | | -__|"); System.out.println("|________||_____||__||____|_____|__|__|__|_____|"); System.out.println("Press Enter to Start"); scan.nextLine(); System.out.println("Press Enter to go to the next line"); //Pressing Enter will make it go to next line scan.nextLine(); System.out.println("This is an adventure game, don't die!"); scan.nextLine(); System.out.println(" ~~~~~~~~~ "); System.out.println("{ Level 1 }"); System.out.println(" ~~~~~~~~~ "); scan.nextLine(); Level myLevel = new Level(); myLevel.badPath(); System.out.println("Pick the correct path"); scan.nextLine(); System.out.println("Path 1 or Path 2"); Path=scan.nextInt(); if (Path == badPath) System.out.println("lose"); else System.out.println("win"); }}
import java.util.Random; public class Level { public int Path=1, badPath; Random gen = new Random(); public int badPath() { badPath = gen.nextInt(0) + 1; return badPath; } }