Answered step by step
Verified Expert Solution
Link Copied!

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 main(String[] args){
// TODO Auto-generated method stub
Scanner kb = new Scanner(System.in);
System.out.println("How high would you like the track to be?(Even numbers will be converted to odd)");
int y = kb.nextInt();
System.out.println("How width would you like the track to be?(Even numbers will be converted to odd)");
int x = kb.nextInt();
//Make sure the sizes are not negative
y = Math.abs(y);
x = Math.abs(x);
//and make sure they are odd values
if(y%2==0)
y++;
if(x%2==0)
x++;
//Create the grid
char [][] grid = new char[x][y];
TrackGenerator.generateMaze(grid,1,1);
//Print the grid to a textfile or "" to print to screen
TrackGenerator.printMatrix(grid,"track");
System.out.println("Done!");
}
}import java.io.File;
import java.io.PrintWriter;
import java.util.Random;
public class TrackGenerator {
private static Random rand = new Random();
private static void fill2DArray(char [][]wood)
{
//Fill the 2D array 'wood' with non-space characters
/*********************************************
* TODO FILL IN CODE HERE
*********************************************/
}
private static void carveTrack(char [][] wood, int x, int y)
{
/*********************************************
* TODO FILL IN CODE HERE
*********************************************/
}
private static boolean hasWestNeighbor(char[][] wood, int x, int y)
{
return (x-2)>=1 && wood[x-2][y]!='';
}
private static boolean hasEastNeighbor(char[][] wood, int x, int y)
{
return (x+2)=1 && wood[x][y-2]!='';
}
private static boolean hasSouthNeighbor(char[][] wood, int x, int y)
{
return (y+2)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago