Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java Programming : import java.util.Random; import java.util.Scanner; public class TrackCarver { public static void main ( String [ ] args ) { / / TODO
Java Programming : import java.util.Random;
import java.util.Scanner;
public class TrackCarver
public static void mainString args
TODO Autogenerated method stub
Scanner kb new ScannerSystemin;
System.out.printlnHow high would you like the track to beEven numbers will be converted to odd;
int y kbnextInt;
System.out.printlnHow width would you like the track to beEven numbers will be converted to odd;
int x kbnextInt;
Make sure the sizes are not negative
y Math.absy;
x Math.absx;
and make sure they are odd values
ify
y;
ifx
x;
Create the grid
char grid new charxy;
TrackGenerator.generateMazegrid;
Print the grid to a textfile or to print to screen
TrackGenerator.printMatrixgrid"track";
System.out.printlnDone;
import java.ioFile;
import java.ioPrintWriter;
import java.util.Random;
public class TrackGenerator
private static Random rand new Random;
private static void fillDArraychar wood
Fill the D array 'wood' with nonspace characters
TODO FILL IN CODE HERE
private static void carveTrackchar wood, int x int y
TODO FILL IN CODE HERE
private static boolean hasWestNeighborchar wood, int x int y
return x && woodxy;
private static boolean hasEastNeighborchar wood, int x int y
return x && woodxy;
private static boolean hasSouthNeighborchar wood, int x int y
return y
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