I'm a highschooler who's pretty new to Java. I'm struggling a bit with object oriented programming. I'm not sure how to take an input from a scanner and implement the input into my code. I'm sorry if my question is bad, I'm just not sure how to approach this problem because the textbook I'm using is too complicated.
This is my main file:
import java.io.*;
import java.util.*;
//for best results play in code screen
public class Main {
public static void main(String[] args) {
// calls on the gameStructure file automaticlly so the player wont have to do it
// manually
new GameStructure();
Scanner reader = new Scanner(System.in);
System.out.println("How long do you want your snake to be? For best results make it less then 7 :)?");
public int rad = reader.nextInt();
}
}
This is my second file called GamePanel.java
int bodyParts = parts.rad;
This is the line in which I try to call on the input of the scanner This is the error I'm getting:
int bodyParts = parts.rad;
^
symbol: variable rad
location: variable parts of type Main
1 error
exit status 1
^C