java - Main seems to skip over one of my methods -


apologies posting bit of foolish question, cant seem understand why method startendcoords not seem run through main method here:

import java.util.scanner; import java.io.file; import java.io.filenotfoundexception;  public class mazesolver {  // name of file describing maze static string mazefile;  // set global variables static int arrayheight; static int arraywidth; static int startrow; static int startcolumn; static int endrow; static int endcolumn; static int cellsize; static int borderwidth; static int sleeptime; static char [][] maze;  public static void main(string[] args) throws filenotfoundexception {     if (handlearguments(args)) {         maze = readmazefile(args[0]);         startendcoords(maze);           if (solvemaze(startrow, startcolumn))             system.out.println("solved!");         else             system.out.println("maze has no solution.");     } }  // starting & ending points static boolean startendcoords(char[][] mazeasarray){     (int r = 0; r < mazesolver.arrayheight; r++) {         (int c = 0; c < mazesolver.arraywidth; c++) {             if (mazeasarray[r][c] == 's') {                 mazesolver.startrow = r;                 system.out.println(startrow);                 mazesolver.startcolumn = c;                 system.out.println(startcolumn);             }              if (mazeasarray[r][c] == 'e') {                 mazesolver.endrow = r;                 system.out.println(endrow);                 mazesolver.endcolumn = c;                 system.out.println(endcolumn);                 return true;              }          }     } return false; } 

the print statements within method not execute, not sure im missing.

thanks help.

full code

it appears readmazefile method intended set of global variables declare, doesn't. instead declares own local variables happen have same names, , sets those. leaves mazesolver.arrayheight @ default value of 0, of course loop instantly bails before running once.

remove int lines in readmazefile set arrayheight , arraywidth. make use , set existing static variables instead of creating new local ones.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -