I am creating a program that will outprint the coordinates of a location. When it prints it out to the file, it looks like this:
Car id distance #spots
java.awt.Point[x=1,y=1]
java.awt.Point[x=2,y=0]
java.awt.Point[x=1,y=0]
car0 java.awt.Point[x=0,y=0] java.awt.Point[x=1,y=0] 1
car1 java.awt.Point[x=2,y=0] java.awt.Point[x=2,y=0] 2
I am trying to get rid of the java.awt.Point from showing up so it only shows the coordinates.
Heres my code: public void saveGrid(File name) throws FileNotFoundException {
ArrayList<Car> cars = getCars();
ArrayList<ParkingSpot> spots = getSpots();
PrintWriter fileWriter;
try {
fileWriter = new PrintWriter(name);
fileWriter.println("hi");
fileWriter.println("\n\nCar id distance #spots\n");
fileWriter.println(getPartyLocation());
for(ParkingSpot spot: spots){
fileWriter.println(spot.getLocation());
fileWriter.println("");
}
for (Car car: cars) {
fileWriter.println(car.getId() + " " + car.getStart() + " " + car.getLocation() + " " + car.getNumSpotsTried());
fileWriter.println("");
}
fileWriter.close();
} catch (FileNotFoundException e) {
System.err.println("FileWriting error:" + e);
e.printStackTrace();
}