Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java homework please explain, I am stuck. - Here is the JaggedGridReader code I created and runs properly import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public

Java homework please explain, I am stuck.

- Here is the JaggedGridReader code I created and runs properly

import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class JaggedGridReader { private char[][] grid; // 2D array of characters to store the grid read from file private String fileName; // name of the file to be read // constructor public JaggedGridReader(String fileName) { this.fileName = fileName; readFile(); // call method to read the file and store data in grid } // private method to read the file and store data in grid private void readFile() { try { // create a Scanner object to read the file Scanner scanner = new Scanner(new File(fileName)); int numRows = 0; // loop through each line of the file to get the number of rows while (scanner.hasNextLine()) { numRows++; scanner.nextLine(); } scanner.close(); // close the scanner scanner = new Scanner(new File(fileName)); // initialize the grid with the number of rows grid = new char[numRows][]; for (int i = 0; i  

image text in transcribedimage text in transcribedimage text in transcribed

For this assignment, you'll be developing one java classes and one java program that will use the classes. You will also use the JaggedGridReader that you made from Homework 1. You'll need to put the JaggedGridReader.java file into the hw1/ directory You may (and should) develop and submit your own testing classes in addition to the 2 required classes. The classes that you will create are: 1. - an object that solves a maze as a char [] [] by writing the path onto the array and stores the path as an ArrayList. After creating a MazeSolver, calling solveMaze() will update the maze and return true if a path was found, and false otherwise. If a the maze is solved, then mazessolved will be incremented, and the mazePath will have the list of moves to take to solve the maze otherwise the mazePath will be cleared. In either case (solved or not), the numCellsVisited will be updated and the mazesTried will be incremented. After solveMaze is called, the other public methods can be called. getmoves() should return null if solveMaze hasn't been called or if the last time solveMaze was called it returned false. The UML diagram is below. 2. - This is the program. SolveMazes should repeatedly ask for a file name or the word stop . Each time the file name is not stop, it should use the JaggedgridReader from homework 1 to read the file, use the to solve the maze, then print the solution to the maze along with the number of cells visited, or "No Solution" if the maze was not solved. Once it finishes processing the mazes, it should print the performance of the maze solver as a percentage with no decimal places and then the program should end. For example: Class description - an object for reading files into a 2-D array. - fields 6 final char fields to define the characters representing the maze. maze: the two dimensional char array that holds the current maze. mazePath: the solution to the maze after solving the maze or null if the maze is unsolved. numCellsVisited: the number of cells visited for the current maze solved. mazesSolved: the number of mazesSolved mazesTried: the number of mazesTried - methods solveMaze (... ) : takes a maze, calls findPath, updates mazesTried, updates mazesSolved depending on whether a path was found. : this method recursively searches for a path. If a move leads to the goal, then it should be added to mazePath. If a cell is open and searched (marked), then the should increase. getMoves ( ) : this method should return the mazePath as an array or null if the maze was not solved. : returns the number of cells visited the last time solveMaze was called. this method should return ratio of mazesSolved/mazesTried. Below is an article describing the problem space and algorithm to solve a maze on a character grid. Use this for the class. Below is an article describing the problem space and algorithm to solve a maze on a character grid. Use this for the class. Submission When you submit your 2 class files to the hw 2 directory of this repository they will be tested with the GitHub classroom autograding system. You can submit as many versions of each file until all of the tests pass. The first set of tests will test the Then the program will be tested. All of the test programs are in the test directory and the sample mazes are in the maze directory. Some mazes have no solution

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

WHAT IS AUTOMATION TESTING?

Answered: 1 week ago

Question

What is Selenium? What are the advantages of Selenium?

Answered: 1 week ago

Question

Explain the various collection policies in receivables management.

Answered: 1 week ago