So I have 3 different classes, one: to create State objects, two: to read data from a csv file and pass this data to the State constructor in order to create an ArrayList of State objects, and three: to display this information in a GUI.
the code for two is here:
public class DataReader
{
private ArrayList<State> states = new ArrayList<State>();
private File file = new File("data_11_09.csv");
public ArrayList<State> readData() throws FileNotFoundException {
Scanner read = new Scanner(file);
read.useDelimiter(",");
String stateName;
int infectionNum;
int deathNum;
while (read.hasNextLine()) {
stateName = read.nextLine();
infectionNum = read.nextInt();
deathNum = read.nextInt();
states.add(new State(stateName, infectionNum, deathNum));
}
read.close();
return states;
}
}
and then code for class three:
public class ChartWindow extends Application
{
ArrayList<State> displayStates = new ArrayList<State>();
final double RADIUS = 2000;
int horSpace;
int verSpace;
@Override
public void start(Stage primaryStage) {
}
public State drawState() {
collections.copy(displayStates, states);
}
}
however under the drawState() method im getting the error that the variable "states" can't be found. I'm not sure how to reference the states ArrayList from class two to class three. Any help would be appreciated...sorry if this was long winded but im new here
You could try something like this:
Key points:
Some of the other comments are correct, to succeed in this endeavor you will likely need to spend significant time and effort to study some basic programming tutorials (e.g. "Trails Covering the Basics").