mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
Apply standard code style
Sadly, standard does not support private fields (yet)
This commit is contained in:
@@ -108,13 +108,6 @@ function getPath (grid) {
|
||||
* Creates an instance of the "rat in a maze" based on a given grid (maze).
|
||||
*/
|
||||
export class RatInAMaze {
|
||||
|
||||
/** Path from the source [0, 0] to the target [N-1, N-1]. */
|
||||
#_path = ''
|
||||
|
||||
/** Whether the rat could find a way to the target or not. */
|
||||
#_solved = false
|
||||
|
||||
constructor (grid) {
|
||||
// first, let's do some error checking on the input
|
||||
validateGrid(grid)
|
||||
@@ -123,17 +116,11 @@ export class RatInAMaze {
|
||||
const solution = getPath(grid)
|
||||
|
||||
if (solution !== false) {
|
||||
this.#_path = solution
|
||||
this.#_solved = true
|
||||
this.path = solution
|
||||
this.solved = true
|
||||
} else {
|
||||
this.path = ''
|
||||
this.solved = false
|
||||
}
|
||||
}
|
||||
|
||||
get solved () {
|
||||
return this.#_solved
|
||||
}
|
||||
|
||||
get path () {
|
||||
return this.#_path
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user