"Error :java.io.FileNotFoundException: sample_maze2.txt (The system cannot find the file specified)"
public class JavaTest { public static void main(String[] args) { TextIO.readFile("sample_maze2.txt"); // sample_maze2.txt has a line with two numbers on it saying how many rows and // how many columns of characters there are in the rest of the file. // All calls to TextIO.get methods read now read from sample_maze2.txt. int rows = TextIO.getInt(); // this is the number of rows in the file (maze) int cols = TextIO.getlnInt(); // this is the number of columns in the file (maze) char[][] array = new char[6][12]; // Each line of sample_maze2.txt contains cols number of characters // and there are rows number of lines for (int i=0; i < rows; i++) { for (int j=0; j < cols; j++) { array[i][j] = TextIO.getChar(); } TextIO.getln(); } TextIO.readStandardInput(); // This closes the file TextIO.putln("Display the maze using 'maze' characters:"); // In the maze project, whenever you read a '0' you display a wall character // whenever you read a '1' you display a path character // whenever you read a '2' you display an entrance character // whenever you read a '3' you display an exit character for (int i=0; i < rows; i++) { for (int j=0; j < cols; j++) { if (array[i][j]=='0') TextIO.put('*'); if (array[i][j]=='1') TextIO.put(' '); if (array[i][j]=='2') TextIO.put('E'); if (array[i][j]=='3') TextIO.put('X'); } TextIO.putln(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)