Removed map.txt file because it changes too much.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -27,3 +27,5 @@ bin/
|
|||||||
|
|
||||||
### Mac OS ###
|
### Mac OS ###
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
map.txt
|
||||||
|
|||||||
@@ -52,10 +52,17 @@ public class PointGraphWriter {
|
|||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PointGraph loadFile(String filename) throws FileNotFoundException, NumberFormatException {
|
public PointGraph loadFile(String filename) throws NumberFormatException {
|
||||||
PointGraph g = new PointGraph();
|
PointGraph g = new PointGraph();
|
||||||
File file = new File(filename);
|
File file = new File(filename);
|
||||||
Scanner reader = new Scanner(file);
|
Scanner reader;
|
||||||
|
try {
|
||||||
|
reader = new Scanner(file);
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException e){
|
||||||
|
System.out.println("File not found");
|
||||||
|
return g;
|
||||||
|
}
|
||||||
ArrayList<PointVertex> vertices = new ArrayList<>();
|
ArrayList<PointVertex> vertices = new ArrayList<>();
|
||||||
while(reader.hasNextLine()){
|
while(reader.hasNextLine()){
|
||||||
String line = reader.nextLine();
|
String line = reader.nextLine();
|
||||||
|
|||||||
@@ -79,15 +79,10 @@ public class Processing extends PApplet {
|
|||||||
}
|
}
|
||||||
if(key == 'l'){
|
if(key == 'l'){
|
||||||
System.out.println("Attempting to load a map from file");
|
System.out.println("Attempting to load a map from file");
|
||||||
try{
|
PointGraphWriter writer = new PointGraphWriter();
|
||||||
PointGraphWriter writer = new PointGraphWriter();
|
try {
|
||||||
map = writer.loadFile("map.txt");
|
map = writer.loadFile("map.txt");
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
catch (FileNotFoundException e){
|
|
||||||
System.out.println("File not found");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (NumberFormatException e){
|
|
||||||
System.out.println("Number format incorrect");
|
System.out.println("Number format incorrect");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user