I am trying to create waypoints from a given file waypoints.txt
I first created the waypoint class
import java.io.*;
import java.util.*;
import java.util.HashMap;
import java.util.Iterator;
public class waypoint {
int x;
int y;
int height;
int cost;
int gold;
int mapX;
int mapY;
public waypoint(int myX,int myY,int myHeight,int myCost,int myGold,int myMapX,int myMapY){
myX=x;
myY=y;
myHeight=height;
myCost=cost;
myGold=gold;
myMapX=mapX;
myMapY=y;
}
public int myHashKey(){
String hashable=(Integer.toString(x)+Integer.toString(y)+Integer.toString(height)+Integer.toString(cost)+Integer.toString(gold)+Integer.toString(mapX)+Integer.toString(mapY));
return hashable.hashCode();
}
}
then i tried reading it and creating the waypoints using this...
public void waypoints(String[] args) throws FileNotFoundException {
Scanner wps = new Scanner(new FileReader("waypoints.txt"));
while(wps.hasNextInt()){
if(wps.hasNextInt()){
waypoint w = new waypoint(wps.nextInt(),wps.nextInt(),wps.nextInt(),wps.nextInt(),wps.nextInt(),wps.nextInt(),wps.nextInt());
animatePanel.addPermanentDrawable(new Marker((int) w.x,(int) w.y, Color.black));
}
}
}
and it wasn't creating anything so i tried printing w.x to see what it was putting and i just get 0's not sure why, if you could point me in the right direction it would be much aprectiated.