Hey programmers. I've been at this program for a little over two weeks, and could really use some expert help. Basically, I'm trying to read a text file into two integers x and y (which will be used later for coordinates). I've created a vertex class to get/set the x and y coordinates. Lastly, I'm trying to pass the coordinates into a Linked List. I've implemented the Linked List class with helper methods, and everything is fine in that class. In the main program I'm getting an error that says, "cannot find symbol." Please help. I've included code.
args){ CircLinkedList<Vertex> vertexList = new CircLinkedList<Vertex>(); String fileName = "test.txt"; File file = new File(fileName); try{ Scanner inputStream = new Scanner(file); while(inputStream.hasNext()){ String data = inputStream.next(); String[] values = data.split(","); int x = Integer.parseInt(values[1]); int y = Integer.parseInt(values[2]); } inputStream.close(); } catch(FileNotFoundException e){ System.out.print("File not found"); } Vertex coordinates = new Vertex(x,y); vertexList.addFirst(coordinates); } }
and the vertex class
import java.util.*; public class Vertex { int xCord; int yCord; double n; public Vertex(int x, int y){ xCord = x; yCord = y; n = (Double) null; } public int getX(){ return xCord; } public int getY(){ return yCord; } public double getN(){ return n; } public void setX(int x){ xCord = x; } public void setY(int y){ yCord = y; } public void setN(double n){ this.n = n; } }
thanks again.