Question
fix my java code from actual result to become expected result here is the code: import java.util.Collections; import java.util.Arrays; public class MazeGenerator { private final
fix my java code from actual result to become expected result
here is the code:
import java.util.Collections; import java.util.Arrays;
public class MazeGenerator { private final int x; private final int y; private final int[][] maze;
public MazeGenerator(int x, int y) { this.x = x; this.y = y; maze = new int[this.x][this.y]; generateMaze(0, 0); }
public void display() { for (int i = 0; i
}
private void generateMaze(int cx, int cy) { DIR[] dirs = DIR.values(); Collections.shuffle(Arrays.asList(dirs)); for (DIR dir : dirs) { int nx = cx + dir.dx; int ny = cy + dir.dy; if (nx
private static boolean between(int v, int upper) { return (v >= 0) && (v
private enum DIR { N(1, 0, -1), S(2, 0, 1), E(4, 1, 0), W(8, -1, 0); private final int bit; private final int dx; private final int dy; private DIR opposite; // use the static initializer to resolve forward references static { N.opposite = S; S.opposite = N; W.opposite = E; E.opposite = W; }
private DIR(int bit, int dx, int dy) { this.bit = bit; this.dx = dx; this.dy = dy; } }
public static void main(String[] args) { int x = args.length >= 1 ? Integer.parseInt(args[0]) : 11; int y = args.length == 2 ? Integer.parseInt(args[1]) : 11; MazeGenerator maze = new MazeGenerator(x, y); maze.display(); } }
actual result: expected result :
++1+1+1+++++++++++++++++++|++++++++++++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started