Big Java Late Objects
Big Java Late Objects
2nd Edition
ISBN: 9781119330455
Author: Horstmann
Publisher: WILEY
Question
Book Icon
Chapter 15, Problem 21PE
Program Plan Intro

Maze

Program plan:

Maze.java

  • Create a class named “Maze”. Inside the class,
    • Declare the required variables
    • Define the “Maze ()” method.
      • Initialize the values.
    • Define the “pathsFrom ()” method.
      • Create an array list.
      • Use necessary conditions to validate the rows and columns.
      • Return the path required after validation.
      • Loop that iterates for the path
      • Call the method “extend()”
    • Define the “extend ()” method.
      • Assign the value
      • Loop that iterates for validating the path and position whether there is a straight path or a turn required.
      • Else make the visit to the next rows and column to explore the path
    • Define the “isExit ()” method.
      • Return the position.
    • Define the “isDeadEnd ()” method.
      • Return true if the position is dead end
    • Define the “isValid ()” method.
      • Return true is the position is valid
    • Define the “countNeighbors ()” method.
      • Condition to validate the neighbors are with the maze and not with the walls.
      • Return the count

MazeSolver.java

  • Create a class named “MazeSolver”. Inside the class,
    • Define the method “solve ()”
      • Create a new stack
      • Set for the visited intersection is defined.
      • Add the required rows and columns.
      • Loop that iterates for the path
        • Move to the path
      • Loop that iterates for the size of the stack.
        • Assign the required path.
        • Assign the required row and columns
        • Use necessary condition to validate the maze rows and columns and display the appropriate messages.

MazeSolverDemo.java

  • Create a class named “MazeSolverDemo”. Inside the class,
    • Define the method “main ()”
      • Define the maze.
      • Call the method to solve the maze.

Path.java

  • Create a class named “Path”. Inside the class,
    • Define the required variables.
    • Define the method “path ()”
      • Initialize the required variables.
    • Define the method “move ()”
      • Assign the row and columns.
    • Define the method “turn ()”
      • Assign the direction
      • Calculate the ending direction.
    • Define the method “getEndingRow ()”
      • Return the end row.
    • Define the method “getEndingColumn ()”
      • Return the end columns.
    • Define the method “getNextRow ()”
      • Return the next row.
    • Define the method “getNextColumn ()”
      • Return the next columns
    • Define the method “isOpposite ()”
      • Return true if direction are opposite
    • Define the method “isOpposite ()”
      • Return true if direction are opposite
    • Define the method “toString ()”
      • Assign the result.
      • Condition to validate the rows and columns
      • Return the result.

Blurred answer

Chapter 15 Solutions

Big Java Late Objects

Ch. 15.3 - Prob. 11SCCh. 15.3 - Prob. 12SCCh. 15.3 - Prob. 13SCCh. 15.3 - Prob. 14SCCh. 15.3 - Prob. 15SCCh. 15.4 - Prob. 16SCCh. 15.4 - Prob. 17SCCh. 15.4 - Prob. 18SCCh. 15.4 - Prob. 19SCCh. 15.4 - Prob. 20SCCh. 15.5 - Prob. 21SCCh. 15.5 - Prob. 22SCCh. 15.5 - Prob. 23SCCh. 15.5 - Prob. 24SCCh. 15.5 - Prob. 25SCCh. 15.6 - Prob. 26SCCh. 15.6 - Prob. 27SCCh. 15.6 - Prob. 28SCCh. 15.6 - Prob. 29SCCh. 15.6 - Prob. 30SCCh. 15 - Prob. 1RECh. 15 - Prob. 2RECh. 15 - Prob. 3RECh. 15 - Prob. 4RECh. 15 - Prob. 5RECh. 15 - Prob. 6RECh. 15 - Prob. 7RECh. 15 - Prob. 8RECh. 15 - Prob. 9RECh. 15 - Prob. 10RECh. 15 - Prob. 11RECh. 15 - Prob. 12RECh. 15 - Prob. 13RECh. 15 - Prob. 14RECh. 15 - Prob. 15RECh. 15 - Prob. 16RECh. 15 - Prob. 17RECh. 15 - Prob. 18RECh. 15 - Prob. 19RECh. 15 - Prob. 20RECh. 15 - Prob. 21RECh. 15 - Prob. 22RECh. 15 - Prob. 23RECh. 15 - Prob. 24RECh. 15 - Prob. 25RECh. 15 - Prob. 26RECh. 15 - Prob. 1PECh. 15 - Prob. 2PECh. 15 - Prob. 3PECh. 15 - Prob. 4PECh. 15 - Prob. 5PECh. 15 - Prob. 6PECh. 15 - Prob. 7PECh. 15 - Prob. 8PECh. 15 - Prob. 9PECh. 15 - Prob. 10PECh. 15 - Prob. 11PECh. 15 - Prob. 12PECh. 15 - Prob. 13PECh. 15 - Prob. 14PECh. 15 - Prob. 15PECh. 15 - Prob. 16PECh. 15 - Prob. 17PECh. 15 - Prob. 18PECh. 15 - Prob. 19PECh. 15 - Prob. 20PECh. 15 - Prob. 21PECh. 15 - Prob. 22PECh. 15 - Prob. 1PPCh. 15 - Prob. 2PPCh. 15 - Prob. 3PPCh. 15 - Prob. 4PPCh. 15 - Prob. 5PPCh. 15 - Prob. 6PPCh. 15 - Prob. 7PPCh. 15 - Prob. 8PPCh. 15 - Prob. 9PPCh. 15 - Prob. 10PPCh. 15 - Prob. 11PPCh. 15 - Prob. 12PPCh. 15 - Prob. 13PPCh. 15 - Prob. 14PP
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education